Commit 01431a0e authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Merge remote-tracking branch 'origin/nrLDPC_coding_improvements_3' into...

Merge remote-tracking branch 'origin/nrLDPC_coding_improvements_3' into integration_2025_w08 (!3227)

fix(nrLDPC_coding): timers in DL encoding, fix(ldpctest): Confusion in sizes

Main improvements:

1. fix(ldpctest): Confusion in sizes
   IMPORTANT: This fix makes that ldpctest now works with BG2 and K' != K!
   (Worth double checking with more cases than I did check with though)
   The variable block_length had an ambiguous role and was used as both K and
   Kprime. This was leading to arrays with wrong sizes and functions with wrong
   arguments. Now there is not anymore block_length but K and Kprime.
   Kprime can be set with the command line argument -l.
   There was also some problems with array allocation for segments with length
   not divisible by 8. A proper sizing with ((size_in_bits + 7) & ~7) / 8 was
   used.
   A proper masking of the last byte containing payload bits was also added to
   keep filler bits to 0 after random initialization.

2. fix(nrLDPC_coding): timers in DL encoding
   While timers were available for rate matching and interleaving in the new
   interface, these timers were not merged to rate matching and interleaving
   timers in nr_dlsch_coding.
parents 76eb5c17 9dada89c
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
<htmlTabRef>test-ldpc-gpu</htmlTabRef> <htmlTabRef>test-ldpc-gpu</htmlTabRef>
<htmlTabName>Test-ldpc-GPU</htmlTabName> <htmlTabName>Test-ldpc-GPU</htmlTabName>
<htmlTabIcon>tasks</htmlTabIcon> <htmlTabIcon>tasks</htmlTabIcon>
<TestCaseRequestedList>000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021</TestCaseRequestedList> <TestCaseRequestedList>
000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021
000022 000023 000024 000025 000026 000027 000028 000029 000030 000031 000032 000033 000034 000035 000036 000037 000038 000039 000040 000041
</TestCaseRequestedList>
<TestCaseExclusionList></TestCaseExclusionList> <TestCaseExclusionList></TestCaseExclusionList>
<testCase id="000002"> <testCase id="000002">
...@@ -188,6 +191,166 @@ ...@@ -188,6 +191,166 @@
<physim_run_args>-l 8448 -s10 -n100 -G 1</physim_run_args> <physim_run_args>-l 8448 -s10 -n100 -G 1</physim_run_args>
</testCase> </testCase>
<testCase id="000022">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 1 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000023">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 1 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000024">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 100 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000025">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 100 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000026">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 193 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000027">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 193 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000028">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 500 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000029">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 500 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000030">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 561 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000031">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 561 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000032">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 600 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000033">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 600 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000034">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 641 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000035">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 641 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000036">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 2000 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000037">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 2000 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000038">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 3000 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000039">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 3000 -s10 -n100 -G 1</physim_run_args>
</testCase>
<testCase id="000040">
<class>Run_Physim</class>
<desc>Run LDPC Test with CPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 3840 -s10 -n100</physim_run_args>
</testCase>
<testCase id="000041">
<class>Run_Physim</class>
<desc>Run LDPC Test with GPU</desc>
<always_exec>true</always_exec>
<physim_test>ldpctest</physim_test>
<physim_run_args>-l 3840 -s10 -n100 -G 1</physim_run_args>
</testCase>
</testCaseList> </testCaseList>
...@@ -66,16 +66,26 @@ ...@@ -66,16 +66,26 @@
</testCase> </testCase>
<testCase id="ldpctest"> <testCase id="ldpctest">
<desc>ldpc Test cases. (Test1: block length = 3872), <desc>ldpc Test cases. (Test1: block length = 3872, BG1),
(Test2: block length = 4224), (Test2: block length = 4224, BG1),
(Test3: block length = 4576), (Test3: block length = 4576, BG1),
(Test4: block length = 4928), (Test4: block length = 4928, BG1),
(Test5: block length = 5280), (Test5: block length = 5280, BG1),
(Test6: block length = 5632), (Test6: block length = 5632, BG1),
(Test7: block length = 6336), (Test7: block length = 6336, BG1),
(Test8: block length = 7040), (Test8: block length = 7040, BG1),
(Test9: block length = 7744), (Test9: block length = 7744, BG1),
(Test10: block length = 8448)</desc> (Test10: block length = 8448, BG1),
(Test11: block length = 1, BG2),
(Test12: block length = 100, BG2),
(Test13: block length = 193, BG2),
(Test14: block length = 500, BG2),
(Test15: block length = 561, BG2),
(Test16: block length = 600, BG2),
(Test17: block length = 641, BG2),
(Test18: block length = 2000, BG2),
(Test19: block length = 3000, BG2),
(Test20: block length = 3840, BG2)</desc>
<main_exec>ldpctest</main_exec> <main_exec>ldpctest</main_exec>
<main_exec_args>-l3872 -s10 -n100 <main_exec_args>-l3872 -s10 -n100
-l4224 -s10 -n100 -l4224 -s10 -n100
...@@ -87,9 +97,17 @@ ...@@ -87,9 +97,17 @@
-l7040 -s10 -n100 -l7040 -s10 -n100
-l7744 -s10 -n100 -l7744 -s10 -n100
-l8448 -s10 -n100 -l8448 -s10 -n100
-l561 -s10 -n1 -l1 -s10 -n100
-l500 -s10 -n1</main_exec_args> -l100 -s10 -n100
<tags>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10</tags> -l193 -s10 -n100
-l500 -s10 -n100
-l561 -s10 -n100
-l600 -s10 -n100
-l641 -s10 -n100
-l2000 -s10 -n100
-l3000 -s10 -n100
-l3840 -s10 -n100</main_exec_args>
<tags>test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 test20</tags>
<search_expr_true>BLER 0.000000</search_expr_true> <search_expr_true>BLER 0.000000</search_expr_true>
<search_expr_false>segmentation fault|assertion|exiting|fatal|differ</search_expr_false> <search_expr_false>segmentation fault|assertion|exiting|fatal|differ</search_expr_false>
<nruns>3</nruns> <nruns>3</nruns>
......
This diff is collapsed.
...@@ -49,7 +49,7 @@ typedef struct ldpc8blocks_args_s { ...@@ -49,7 +49,7 @@ typedef struct ldpc8blocks_args_s {
encoder_implemparams_t impp; encoder_implemparams_t impp;
} ldpc8blocks_args_t; } ldpc8blocks_args_t;
static void ldpc8blocks_coding_segment(void *p) static void ldpc8blocks(void *p)
{ {
ldpc8blocks_args_t *args = (ldpc8blocks_args_t *)p; ldpc8blocks_args_t *args = (ldpc8blocks_args_t *)p;
nrLDPC_TB_encoding_parameters_t *nrLDPC_TB_encoding_parameters = args->nrLDPC_TB_encoding_parameters; nrLDPC_TB_encoding_parameters_t *nrLDPC_TB_encoding_parameters = args->nrLDPC_TB_encoding_parameters;
...@@ -192,7 +192,7 @@ static int nrLDPC_prepare_TB_encoding(nrLDPC_slot_encoding_parameters_t *nrLDPC_ ...@@ -192,7 +192,7 @@ static int nrLDPC_prepare_TB_encoding(nrLDPC_slot_encoding_parameters_t *nrLDPC_
perJobImpp->impp = impp; perJobImpp->impp = impp;
perJobImpp->nrLDPC_TB_encoding_parameters = nrLDPC_TB_encoding_parameters; perJobImpp->nrLDPC_TB_encoding_parameters = nrLDPC_TB_encoding_parameters;
task_t t = {.func = ldpc8blocks_coding_segment, .args = perJobImpp}; task_t t = {.func = ldpc8blocks, .args = perJobImpp};
pushTpool(nrLDPC_slot_encoding_parameters->threadPool, t); pushTpool(nrLDPC_slot_encoding_parameters->threadPool, t);
} }
return n_seg; return n_seg;
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
*/ */
/*! \file PHY/NR_TRANSPORT/nr_dlsch_coding_slot.c /*! \file PHY/NR_TRANSPORT/nr_dlsch_coding_slot.c
* \brief Top-level routines for implementing LDPC-coded (DLSCH) transport channels from 38-212, 15.2 * \brief Top-level routines for implementing LDPC-coded (DLSCH) transport channels from 38-212, 15.2
*/ */
#include "PHY/defs_gNB.h" #include "PHY/defs_gNB.h"
#include "PHY/CODING/coding_extern.h" #include "PHY/CODING/coding_extern.h"
...@@ -39,17 +39,17 @@ ...@@ -39,17 +39,17 @@
#include <syscall.h> #include <syscall.h>
#include <openair2/UTIL/OPT/opt.h> #include <openair2/UTIL/OPT/opt.h>
//#define DEBUG_DLSCH_CODING // #define DEBUG_DLSCH_CODING
//#define DEBUG_DLSCH_FREE 1 // #define DEBUG_DLSCH_FREE 1
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch, uint16_t N_RB, const NR_DL_FRAME_PARMS *frame_parms) void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch, uint16_t N_RB, const NR_DL_FRAME_PARMS *frame_parms)
{ {
int max_layers = (frame_parms->nb_antennas_tx<NR_MAX_NB_LAYERS) ? frame_parms->nb_antennas_tx : NR_MAX_NB_LAYERS; int max_layers = (frame_parms->nb_antennas_tx < NR_MAX_NB_LAYERS) ? frame_parms->nb_antennas_tx : NR_MAX_NB_LAYERS;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*max_layers; uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER * max_layers;
if (N_RB != 273) { if (N_RB != 273) {
a_segments = a_segments*N_RB; a_segments = a_segments * N_RB;
a_segments = a_segments/273 +1; a_segments = a_segments / 273 + 1;
} }
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
...@@ -70,16 +70,16 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch, uint16_t N_RB, const NR_DL_FRAME_PARM ...@@ -70,16 +70,16 @@ void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch, uint16_t N_RB, const NR_DL_FRAME_PARM
NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB) NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB)
{ {
int max_layers = (frame_parms->nb_antennas_tx<NR_MAX_NB_LAYERS) ? frame_parms->nb_antennas_tx : NR_MAX_NB_LAYERS; int max_layers = (frame_parms->nb_antennas_tx < NR_MAX_NB_LAYERS) ? frame_parms->nb_antennas_tx : NR_MAX_NB_LAYERS;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*max_layers; //number of segments to be allocated uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER * max_layers; // number of segments to be allocated
if (N_RB != 273) { if (N_RB != 273) {
a_segments = a_segments*N_RB; a_segments = a_segments * N_RB;
a_segments = a_segments/273 +1; a_segments = a_segments / 273 + 1;
} }
LOG_D(PHY,"Allocating %d segments (MAX %d, N_PRB %d)\n",a_segments,MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER,N_RB); LOG_D(PHY, "Allocating %d segments (MAX %d, N_PRB %d)\n", a_segments, MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER, N_RB);
uint32_t dlsch_bytes = a_segments*1056; // allocated bytes per segment uint32_t dlsch_bytes = a_segments * 1056; // allocated bytes per segment
NR_gNB_DLSCH_t dlsch; NR_gNB_DLSCH_t dlsch;
NR_DL_gNB_HARQ_t *harq = &dlsch.harq_process; NR_DL_gNB_HARQ_t *harq = &dlsch.harq_process;
...@@ -88,7 +88,7 @@ NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB) ...@@ -88,7 +88,7 @@ NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB)
AssertFatal(harq->b, "cannot allocate memory for harq->b\n"); AssertFatal(harq->b, "cannot allocate memory for harq->b\n");
bzero(harq->b, dlsch_bytes); bzero(harq->b, dlsch_bytes);
harq->c = (uint8_t **)malloc16(a_segments*sizeof(uint8_t *)); harq->c = (uint8_t **)malloc16(a_segments * sizeof(uint8_t *));
for (int r = 0; r < a_segments; r++) { for (int r = 0; r < a_segments; r++) {
// account for filler in first segment and CRCs for multiple segment case // account for filler in first segment and CRCs for multiple segment case
// [hna] 8448 is the maximum CB size in NR // [hna] 8448 is the maximum CB size in NR
...@@ -103,7 +103,7 @@ NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB) ...@@ -103,7 +103,7 @@ NR_gNB_DLSCH_t new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB)
AssertFatal(harq->f, "cannot allocate harq->f\n"); AssertFatal(harq->f, "cannot allocate harq->f\n");
bzero(harq->f, N_RB * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS); bzero(harq->f, N_RB * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB * 8 * NR_MAX_NB_LAYERS);
return(dlsch); return (dlsch);
} }
int nr_dlsch_encoding(PHY_VARS_gNB *gNB, int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
...@@ -120,34 +120,30 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -120,34 +120,30 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
time_stats_t *dlsch_interleaving_stats, time_stats_t *dlsch_interleaving_stats,
time_stats_t *dlsch_segmentation_stats) time_stats_t *dlsch_segmentation_stats)
{ {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_IN);
nrLDPC_TB_encoding_parameters_t TBs[msgTx->num_pdsch_slot]; nrLDPC_TB_encoding_parameters_t TBs[msgTx->num_pdsch_slot];
memset(TBs, 0, sizeof(TBs)); memset(TBs, 0, sizeof(TBs));
nrLDPC_slot_encoding_parameters_t slot_parameters = { nrLDPC_slot_encoding_parameters_t slot_parameters = {.frame = frame,
.frame = frame, .slot = slot,
.slot = slot, .nb_TBs = msgTx->num_pdsch_slot,
.nb_TBs = msgTx->num_pdsch_slot, .threadPool = &gNB->threadPool,
.threadPool = &gNB->threadPool, .tinput = tinput,
.tinput = tinput, .tprep = tprep,
.tprep = tprep, .tparity = tparity,
.tparity = tparity, .toutput = toutput,
.toutput = toutput, .TBs = TBs};
.TBs = TBs
};
int num_segments = 0; int num_segments = 0;
for (int dlsch_id=0; dlsch_id<msgTx->num_pdsch_slot; dlsch_id++) { for (int dlsch_id = 0; dlsch_id < msgTx->num_pdsch_slot; dlsch_id++) {
NR_gNB_DLSCH_t *dlsch = msgTx->dlsch[dlsch_id]; NR_gNB_DLSCH_t *dlsch = msgTx->dlsch[dlsch_id];
NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process; NR_DL_gNB_HARQ_t *harq = &dlsch->harq_process;
unsigned int crc=1; unsigned int crc = 1;
nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15; nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &harq->pdsch_pdu.pdsch_pdu_rel15;
uint32_t A = rel15->TBSize[0]<<3; uint32_t A = rel15->TBSize[0] << 3;
unsigned char *a=harq->pdu; unsigned char *a = harq->pdu;
if (rel15->rnti != SI_RNTI) { if (rel15->rnti != SI_RNTI) {
ws_trace_t tmp = {.nr = true, ws_trace_t tmp = {.nr = true,
.direction = DIRECTION_DOWNLINK, .direction = DIRECTION_DOWNLINK,
...@@ -175,38 +171,30 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -175,38 +171,30 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
phy_stats->dlsch_stats.current_Qm = rel15->qamModOrder[0]; phy_stats->dlsch_stats.current_Qm = rel15->qamModOrder[0];
} }
int max_bytes = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*rel15->nrOfLayers*1056; int max_bytes = MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER * rel15->nrOfLayers * 1056;
int B; int B;
if (A > NR_MAX_PDSCH_TBS) { if (A > NR_MAX_PDSCH_TBS) {
// Add 24-bit crc (polynomial A) to payload // Add 24-bit crc (polynomial A) to payload
crc = crc24a(a,A)>>8; crc = crc24a(a, A) >> 8;
a[A>>3] = ((uint8_t *)&crc)[2]; a[A >> 3] = ((uint8_t *)&crc)[2];
a[1+(A>>3)] = ((uint8_t *)&crc)[1]; a[1 + (A >> 3)] = ((uint8_t *)&crc)[1];
a[2+(A>>3)] = ((uint8_t *)&crc)[0]; a[2 + (A >> 3)] = ((uint8_t *)&crc)[0];
//printf("CRC %x (A %d)\n",crc,A); // printf("CRC %x (A %d)\n",crc,A);
//printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]); // printf("a0 %d a1 %d a2 %d\n", a[A>>3], a[1+(A>>3)], a[2+(A>>3)]);
B = A + 24; B = A + 24;
// harq->b = a; // harq->b = a;
AssertFatal((A / 8) + 4 <= max_bytes, AssertFatal((A / 8) + 4 <= max_bytes, "A %d is too big (A/8+4 = %d > %d)\n", A, (A / 8) + 4, max_bytes);
"A %d is too big (A/8+4 = %d > %d)\n",
A,
(A / 8) + 4,
max_bytes);
memcpy(harq->b, a, (A / 8) + 4); // why is this +4 if the CRC is only 3 bytes? memcpy(harq->b, a, (A / 8) + 4); // why is this +4 if the CRC is only 3 bytes?
} else { } else {
// Add 16-bit crc (polynomial A) to payload // Add 16-bit crc (polynomial A) to payload
crc = crc16(a,A)>>16; crc = crc16(a, A) >> 16;
a[A>>3] = ((uint8_t *)&crc)[1]; a[A >> 3] = ((uint8_t *)&crc)[1];
a[1+(A>>3)] = ((uint8_t *)&crc)[0]; a[1 + (A >> 3)] = ((uint8_t *)&crc)[0];
//printf("CRC %x (A %d)\n",crc,A); // printf("CRC %x (A %d)\n",crc,A);
//printf("a0 %d a1 %d \n", a[A>>3], a[1+(A>>3)]); // printf("a0 %d a1 %d \n", a[A>>3], a[1+(A>>3)]);
B = A + 16; B = A + 16;
// harq->b = a; // harq->b = a;
AssertFatal((A / 8) + 3 <= max_bytes, AssertFatal((A / 8) + 3 <= max_bytes, "A %d is too big (A/8+3 = %d > %d)\n", A, (A / 8) + 3, max_bytes);
"A %d is too big (A/8+3 = %d > %d)\n",
A,
(A / 8) + 3,
max_bytes);
memcpy(harq->b, a, (A / 8) + 3); // using 3 bytes to mimic the case of 24 bit crc memcpy(harq->b, a, (A / 8) + 3); // using 3 bytes to mimic the case of 24 bit crc
} }
...@@ -228,12 +216,11 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -228,12 +216,11 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
TB_parameters->BG); TB_parameters->BG);
stop_meas(dlsch_segmentation_stats); stop_meas(dlsch_segmentation_stats);
if (TB_parameters->C>MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER*rel15->nrOfLayers) { if (TB_parameters->C > MAX_NUM_NR_DLSCH_SEGMENTS_PER_LAYER * rel15->nrOfLayers) {
LOG_E(PHY, "nr_segmentation.c: too many segments %d, B %d\n", TB_parameters->C, B); LOG_E(PHY, "nr_segmentation.c: too many segments %d, B %d\n", TB_parameters->C, B);
return(-1); return (-1);
} }
num_segments += TB_parameters->C; num_segments += TB_parameters->C;
} }
nrLDPC_segment_encoding_parameters_t segments[num_segments]; nrLDPC_segment_encoding_parameters_t segments[num_segments];
...@@ -284,18 +271,13 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -284,18 +271,13 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
for (int r = 0; r < TB_parameters->C; r++) { for (int r = 0; r < TB_parameters->C; r++) {
nrLDPC_segment_encoding_parameters_t *segment_parameters = &TB_parameters->segments[r]; nrLDPC_segment_encoding_parameters_t *segment_parameters = &TB_parameters->segments[r];
segment_parameters->c = harq->c[r]; segment_parameters->c = harq->c[r];
segment_parameters->E = nr_get_E(TB_parameters->G, segment_parameters->E = nr_get_E(TB_parameters->G, TB_parameters->C, TB_parameters->Qm, rel15->nrOfLayers, r);
TB_parameters->C,
TB_parameters->Qm,
rel15->nrOfLayers,
r);
segment_parameters->output = &output[dlsch_offset + r_offset]; segment_parameters->output = &output[dlsch_offset + r_offset];
r_offset += segment_parameters->E; r_offset += segment_parameters->E;
reset_meas(&segment_parameters->ts_interleave); reset_meas(&segment_parameters->ts_interleave);
reset_meas(&segment_parameters->ts_rate_match); reset_meas(&segment_parameters->ts_rate_match);
reset_meas(&segment_parameters->ts_ldpc_encode); reset_meas(&segment_parameters->ts_ldpc_encode);
} }
segments_offset += TB_parameters->C; segments_offset += TB_parameters->C;
...@@ -309,6 +291,16 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -309,6 +291,16 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
gNB->nrLDPC_coding_interface.nrLDPC_coding_encoder(&slot_parameters); gNB->nrLDPC_coding_interface.nrLDPC_coding_encoder(&slot_parameters);
for (int dlsch_id = 0; dlsch_id < msgTx->num_pdsch_slot; dlsch_id++) {
nrLDPC_TB_encoding_parameters_t *TB_parameters = &TBs[dlsch_id];
for (int r = 0; r < TB_parameters->C; r++) {
nrLDPC_segment_encoding_parameters_t *segment_parameters = &TB_parameters->segments[r];
merge_meas(dlsch_interleaving_stats, &segment_parameters->ts_interleave);
merge_meas(dlsch_rate_matching_stats, &segment_parameters->ts_rate_match);
// merge_meas(, &segment_parameters->ts_ldpc_encode);
}
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_DLSCH_ENCODING, VCD_FUNCTION_OUT);
return 0; return 0;
} }
...@@ -20,9 +20,8 @@ ...@@ -20,9 +20,8 @@
*/ */
/*! \file PHY/NR_TRANSPORT/nr_ulsch_decoding_slot.c /*! \file PHY/NR_TRANSPORT/nr_ulsch_decoding_slot.c
* \brief Top-level routines for decoding LDPC (ULSCH) transport channels from 38.212, V15.4.0 2018-12 * \brief Top-level routines for decoding LDPC (ULSCH) transport channels from 38.212, V15.4.0 2018-12
*/ */
// [from gNB coding] // [from gNB coding]
#include "PHY/defs_gNB.h" #include "PHY/defs_gNB.h"
...@@ -41,27 +40,26 @@ ...@@ -41,27 +40,26 @@
#include "common/utils/LOG/vcd_signal_dumper.h" #include "common/utils/LOG/vcd_signal_dumper.h"
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
#include <syscall.h> #include <syscall.h>
//#define DEBUG_ULSCH_DECODING // #define DEBUG_ULSCH_DECODING
//#define gNB_DEBUG_TRACE // #define gNB_DEBUG_TRACE
#define OAI_UL_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384 #define OAI_UL_LDPC_MAX_NUM_LLR 27000 // 26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384
//#define DEBUG_CRC // #define DEBUG_CRC
#ifdef DEBUG_CRC #ifdef DEBUG_CRC
#define PRINT_CRC_CHECK(a) a #define PRINT_CRC_CHECK(a) a
#else #else
#define PRINT_CRC_CHECK(a) #define PRINT_CRC_CHECK(a)
#endif #endif
//extern double cpuf; // extern double cpuf;
void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch, uint16_t N_RB_UL) void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch, uint16_t N_RB_UL)
{ {
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER * NR_MAX_NB_LAYERS; // number of segments to be allocated
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated
if (N_RB_UL != 273) { if (N_RB_UL != 273) {
a_segments = a_segments*N_RB_UL; a_segments = a_segments * N_RB_UL;
a_segments = a_segments/273 +1; a_segments = a_segments / 273 + 1;
} }
if (ulsch->harq_process) { if (ulsch->harq_process) {
...@@ -83,12 +81,11 @@ void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch, uint16_t N_RB_UL) ...@@ -83,12 +81,11 @@ void free_gNB_ulsch(NR_gNB_ULSCH_t *ulsch, uint16_t N_RB_UL)
NR_gNB_ULSCH_t new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) NR_gNB_ULSCH_t new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL)
{ {
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER * NR_MAX_NB_LAYERS; // number of segments to be allocated
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER*NR_MAX_NB_LAYERS; //number of segments to be allocated
if (N_RB_UL != 273) { if (N_RB_UL != 273) {
a_segments = a_segments*N_RB_UL; a_segments = a_segments * N_RB_UL;
a_segments = a_segments/273 +1; a_segments = a_segments / 273 + 1;
} }
uint32_t ulsch_bytes = a_segments * 1056; // allocated bytes per segment uint32_t ulsch_bytes = a_segments * 1056; // allocated bytes per segment
...@@ -110,7 +107,7 @@ NR_gNB_ULSCH_t new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL) ...@@ -110,7 +107,7 @@ NR_gNB_ULSCH_t new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL)
} }
harq->d_to_be_cleared = calloc(a_segments, sizeof(bool)); harq->d_to_be_cleared = calloc(a_segments, sizeof(bool));
AssertFatal(harq->d_to_be_cleared != NULL, "out of memory\n"); AssertFatal(harq->d_to_be_cleared != NULL, "out of memory\n");
return(ulsch); return (ulsch);
} }
int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
...@@ -121,18 +118,15 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -121,18 +118,15 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
uint8_t *ULSCH_ids, uint8_t *ULSCH_ids,
int nb_pusch) int nb_pusch)
{ {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING, 1); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING, 1);
nrLDPC_TB_decoding_parameters_t TBs[nb_pusch]; nrLDPC_TB_decoding_parameters_t TBs[nb_pusch];
memset(TBs, 0, sizeof(TBs)); memset(TBs, 0, sizeof(TBs));
nrLDPC_slot_decoding_parameters_t slot_parameters = { nrLDPC_slot_decoding_parameters_t slot_parameters = {.frame = frame,
.frame = frame, .slot = nr_tti_rx,
.slot = nr_tti_rx, .nb_TBs = nb_pusch,
.nb_TBs = nb_pusch, .threadPool = &phy_vars_gNB->threadPool,
.threadPool = &phy_vars_gNB->threadPool, .TBs = TBs};
.TBs = TBs
};
int max_num_segments = 0; int max_num_segments = 0;
...@@ -154,17 +148,17 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -154,17 +148,17 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
// The harq_pid is not unique among the active HARQ processes in the instance so we use ULSCH_id instead // The harq_pid is not unique among the active HARQ processes in the instance so we use ULSCH_id instead
TB_parameters->harq_unique_pid = ULSCH_id; TB_parameters->harq_unique_pid = ULSCH_id;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
TB_parameters->nb_rb = pusch_pdu->rb_size; TB_parameters->nb_rb = pusch_pdu->rb_size;
TB_parameters->Qm = pusch_pdu->qam_mod_order; TB_parameters->Qm = pusch_pdu->qam_mod_order;
TB_parameters->mcs = pusch_pdu->mcs_index; TB_parameters->mcs = pusch_pdu->mcs_index;
TB_parameters->nb_layers = pusch_pdu->nrOfLayers; TB_parameters->nb_layers = pusch_pdu->nrOfLayers;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
TB_parameters->processedSegments = &harq_process->processedSegments; TB_parameters->processedSegments = &harq_process->processedSegments;
harq_process->TBS = pusch_pdu->pusch_data.tb_size; harq_process->TBS = pusch_pdu->pusch_data.tb_size;
TB_parameters->BG = pusch_pdu->maintenance_parms_v3.ldpcBaseGraph; TB_parameters->BG = pusch_pdu->maintenance_parms_v3.ldpcBaseGraph;
TB_parameters->A = (harq_process->TBS) << 3; TB_parameters->A = (harq_process->TBS) << 3;
NR_gNB_PHY_STATS_t *stats = get_phy_stats(phy_vars_gNB, ulsch->rnti); NR_gNB_PHY_STATS_t *stats = get_phy_stats(phy_vars_gNB, ulsch->rnti);
...@@ -181,7 +175,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -181,7 +175,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
stats->ulsch_stats.total_bytes_tx += harq_process->TBS; stats->ulsch_stats.total_bytes_tx += harq_process->TBS;
} }
} }
uint8_t harq_pid = ulsch->harq_pid; uint8_t harq_pid = ulsch->harq_pid;
LOG_D(PHY, LOG_D(PHY,
"ULSCH Decoding, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new RX %d\n", "ULSCH Decoding, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new RX %d\n",
...@@ -197,7 +191,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -197,7 +191,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
pusch_pdu->pusch_data.rv_index, pusch_pdu->pusch_data.rv_index,
harq_process->round, harq_process->round,
harq_process->harq_to_be_cleared); harq_process->harq_to_be_cleared);
// [hna] Perform nr_segmenation with input and output set to NULL to calculate only (C, K, Z, F) // [hna] Perform nr_segmenation with input and output set to NULL to calculate only (C, K, Z, F)
nr_segmentation(NULL, nr_segmentation(NULL,
NULL, NULL,
...@@ -211,40 +205,34 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -211,40 +205,34 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
harq_process->K = TB_parameters->K; harq_process->K = TB_parameters->K;
harq_process->Z = TB_parameters->Z; harq_process->Z = TB_parameters->Z;
harq_process->F = TB_parameters->F; harq_process->F = TB_parameters->F;
uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER * TB_parameters->nb_layers; // number of segments to be allocated uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS_PER_LAYER * TB_parameters->nb_layers; // number of segments to be allocated
if (TB_parameters->C > a_segments) { if (TB_parameters->C > a_segments) {
LOG_E(PHY, "nr_segmentation.c: too many segments %d, A %d\n", harq_process->C, TB_parameters->A); LOG_E(PHY, "nr_segmentation.c: too many segments %d, A %d\n", harq_process->C, TB_parameters->A);
return(-1); return (-1);
} }
if (TB_parameters->nb_rb != 273) { if (TB_parameters->nb_rb != 273) {
a_segments = a_segments*TB_parameters->nb_rb; a_segments = a_segments * TB_parameters->nb_rb;
a_segments = a_segments/273 +1; a_segments = a_segments / 273 + 1;
} }
if (TB_parameters->C > a_segments) { if (TB_parameters->C > a_segments) {
LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments); LOG_E(PHY, "Illegal harq_process->C %d > %d\n", harq_process->C, a_segments);
return -1; return -1;
} }
max_num_segments = max(max_num_segments, TB_parameters->C); max_num_segments = max(max_num_segments, TB_parameters->C);
#ifdef DEBUG_ULSCH_DECODING #ifdef DEBUG_ULSCH_DECODING
printf("ulsch decoding nr segmentation Z %d\n", TB_parameters->Z); printf("ulsch decoding nr segmentation Z %d\n", TB_parameters->Z);
if (!frame % 100) if (!frame % 100)
printf("K %d C %d Z %d \n", printf("K %d C %d Z %d \n", TB_parameters->K, TB_parameters->C, TB_parameters->Z);
TB_parameters->K, printf("Segmentation: C %d, K %d\n", TB_parameters->C, TB_parameters->K);
TB_parameters->C,
TB_parameters->Z);
printf("Segmentation: C %d, K %d\n",
TB_parameters->C,
TB_parameters->K);
#endif #endif
TB_parameters->max_ldpc_iterations = ulsch->max_ldpc_iterations; TB_parameters->max_ldpc_iterations = ulsch->max_ldpc_iterations;
TB_parameters->rv_index = pusch_pdu->pusch_data.rv_index; TB_parameters->rv_index = pusch_pdu->pusch_data.rv_index;
TB_parameters->tbslbrm = pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes; TB_parameters->tbslbrm = pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes;
TB_parameters->abort_decode = &harq_process->abort_decode; TB_parameters->abort_decode = &harq_process->abort_decode;
set_abort(&harq_process->abort_decode, false); set_abort(&harq_process->abort_decode, false);
} }
nrLDPC_segment_decoding_parameters_t segments[nb_pusch][max_num_segments]; nrLDPC_segment_decoding_parameters_t segments[nb_pusch][max_num_segments];
...@@ -267,11 +255,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -267,11 +255,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
uint32_t r_offset = 0; uint32_t r_offset = 0;
for (int r = 0; r < TB_parameters->C; r++) { for (int r = 0; r < TB_parameters->C; r++) {
nrLDPC_segment_decoding_parameters_t *segment_parameters = &TB_parameters->segments[r]; nrLDPC_segment_decoding_parameters_t *segment_parameters = &TB_parameters->segments[r];
segment_parameters->E = nr_get_E(TB_parameters->G, segment_parameters->E = nr_get_E(TB_parameters->G, TB_parameters->C, TB_parameters->Qm, TB_parameters->nb_layers, r);
TB_parameters->C,
TB_parameters->Qm,
TB_parameters->nb_layers,
r);
segment_parameters->R = nr_get_R_ldpc_decoder(TB_parameters->rv_index, segment_parameters->R = nr_get_R_ldpc_decoder(TB_parameters->rv_index,
segment_parameters->E, segment_parameters->E,
TB_parameters->BG, TB_parameters->BG,
...@@ -296,7 +280,6 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -296,7 +280,6 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
} }
harq_process->harq_to_be_cleared = false; harq_process->harq_to_be_cleared = false;
} }
} }
int ret_decoder = phy_vars_gNB->nrLDPC_coding_interface.nrLDPC_coding_decoder(&slot_parameters); int ret_decoder = phy_vars_gNB->nrLDPC_coding_interface.nrLDPC_coding_decoder(&slot_parameters);
...@@ -314,7 +297,9 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -314,7 +297,9 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
nrLDPC_segment_decoding_parameters_t nrLDPC_segment_decoding_parameters = TB_parameters.segments[r]; nrLDPC_segment_decoding_parameters_t nrLDPC_segment_decoding_parameters = TB_parameters.segments[r];
// Copy c to b in case of decoding success // Copy c to b in case of decoding success
if (nrLDPC_segment_decoding_parameters.decodeSuccess) { if (nrLDPC_segment_decoding_parameters.decodeSuccess) {
memcpy(harq_process->b + offset, harq_process->c[r], (harq_process->K >> 3) - (harq_process->F >> 3) - ((harq_process->C > 1) ? 3 : 0)); memcpy(harq_process->b + offset,
harq_process->c[r],
(harq_process->K >> 3) - (harq_process->F >> 3) - ((harq_process->C > 1) ? 3 : 0));
} else { } else {
LOG_D(PHY, "uplink segment error %d/%d\n", r, harq_process->C); LOG_D(PHY, "uplink segment error %d/%d\n", r, harq_process->C);
LOG_D(PHY, "ULSCH %d in error\n", ULSCH_id); LOG_D(PHY, "ULSCH %d in error\n", ULSCH_id);
......
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