Commit a51fa4f3 authored by Francesco Mani's avatar Francesco Mani

changing segments and sch bytes allocation in coding/decoding

parent 0c408e96
...@@ -118,19 +118,15 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -118,19 +118,15 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
NR_gNB_DLSCH_t *dlsch; NR_gNB_DLSCH_t *dlsch;
unsigned char exit_flag = 0,i,r,aa,layer; unsigned char exit_flag = 0,i,r,aa,layer;
int re; int re;
unsigned char bw_scaling =1;
uint16_t N_RB = config->rf_config.dl_carrier_bandwidth.value; uint16_t N_RB = config->rf_config.dl_carrier_bandwidth.value;
uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
switch (N_RB) { if (N_RB != 273) {
a_segments = a_segments*N_RB;
a_segments = a_segments/273;
}
case 106: uint16_t dlsch_bytes = a_segments*1056; // allocated bytes per segment
bw_scaling =2;
break;
default:
bw_scaling =1;
break;
}
dlsch = (NR_gNB_DLSCH_t *)malloc16(sizeof(NR_gNB_DLSCH_t)); dlsch = (NR_gNB_DLSCH_t *)malloc16(sizeof(NR_gNB_DLSCH_t));
...@@ -170,31 +166,31 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo, ...@@ -170,31 +166,31 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,
for (i=0; i<Mdlharq; i++) { for (i=0; i<Mdlharq; i++) {
dlsch->harq_processes[i] = (NR_DL_gNB_HARQ_t *)malloc16(sizeof(NR_DL_gNB_HARQ_t)); dlsch->harq_processes[i] = (NR_DL_gNB_HARQ_t *)malloc16(sizeof(NR_DL_gNB_HARQ_t));
LOG_T(PHY, "Required mem size %d (bw scaling %d), dlsch->harq_processes[%d] %p\n", LOG_T(PHY, "Required mem size %d dlsch->harq_processes[%d] %p\n",
MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling,bw_scaling, i,dlsch->harq_processes[i]); dlsch_bytes, i,dlsch->harq_processes[i]);
if (dlsch->harq_processes[i]) { if (dlsch->harq_processes[i]) {
bzero(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t)); bzero(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t));
// dlsch->harq_processes[i]->first_tx=1; // dlsch->harq_processes[i]->first_tx=1;
dlsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); dlsch->harq_processes[i]->b = (unsigned char*)malloc16(dlsch_bytes);
dlsch->harq_processes[i]->pdu = (uint8_t*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); dlsch->harq_processes[i]->pdu = (uint8_t*)malloc16(dlsch_bytes);
if (dlsch->harq_processes[i]->pdu) { if (dlsch->harq_processes[i]->pdu) {
bzero(dlsch->harq_processes[i]->pdu,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); bzero(dlsch->harq_processes[i]->pdu,dlsch_bytes);
nr_emulate_dlsch_payload(dlsch->harq_processes[i]->pdu, (MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling)>>3); nr_emulate_dlsch_payload(dlsch->harq_processes[i]->pdu, (dlsch_bytes)>>3);
} else { } else {
printf("Can't allocate PDU\n"); printf("Can't allocate PDU\n");
exit_flag=1; exit_flag=1;
} }
if (dlsch->harq_processes[i]->b) { if (dlsch->harq_processes[i]->b) {
bzero(dlsch->harq_processes[i]->b,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); bzero(dlsch->harq_processes[i]->b,dlsch_bytes);
} else { } else {
printf("Can't get b\n"); printf("Can't get b\n");
exit_flag=1; exit_flag=1;
} }
if (abstraction_flag==0) { if (abstraction_flag==0) {
for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling; r++) { for (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
// 68*348 = 68*(maximum size of Zc) // 68*348 = 68*(maximum size of Zc)
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "PHY/defs_nr_common.h" #include "PHY/defs_nr_common.h"
#define MAX_NUM_NR_DLSCH_SEGMENTS 16 #define MAX_NUM_NR_DLSCH_SEGMENTS 34
#define MAX_NUM_NR_ULSCH_SEGMENTS MAX_NUM_NR_DLSCH_SEGMENTS #define MAX_NUM_NR_ULSCH_SEGMENTS MAX_NUM_NR_DLSCH_SEGMENTS
#define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056) #define MAX_NR_DLSCH_PAYLOAD_BYTES (MAX_NUM_NR_DLSCH_SEGMENTS*1056)
......
...@@ -101,17 +101,14 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8 ...@@ -101,17 +101,14 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
NR_gNB_ULSCH_t *ulsch; NR_gNB_ULSCH_t *ulsch;
uint8_t exit_flag = 0,i,r; uint8_t exit_flag = 0,i,r;
unsigned char bw_scaling =1; uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
switch (N_RB_UL) { if (N_RB != 273) {
case 106: a_segments = a_segments*N_RB;
bw_scaling =2; a_segments = a_segments/273;
break; }
default: uint16_t ulsch_bytes = a_segments*1056; // allocated bytes per segment
bw_scaling =1;
break;
}
ulsch = (NR_gNB_ULSCH_t *)malloc16(sizeof(NR_gNB_ULSCH_t)); ulsch = (NR_gNB_ULSCH_t *)malloc16(sizeof(NR_gNB_ULSCH_t));
...@@ -130,15 +127,15 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8 ...@@ -130,15 +127,15 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations,uint8_t N_RB_UL, uint8
memset(ulsch->harq_processes[i],0,sizeof(NR_UL_gNB_HARQ_t)); memset(ulsch->harq_processes[i],0,sizeof(NR_UL_gNB_HARQ_t));
ulsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); ulsch->harq_processes[i]->b = (uint8_t*)malloc16(ulsch_bytes);
if (ulsch->harq_processes[i]->b) if (ulsch->harq_processes[i]->b)
memset(ulsch->harq_processes[i]->b,0,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); memset(ulsch->harq_processes[i]->b,0,ulsch_bytes);
else else
exit_flag=3; exit_flag=3;
if (abstraction_flag == 0) { if (abstraction_flag == 0) {
for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling; r++) { for (r=0; r<a_segments; r++) {
ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); ulsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
...@@ -413,21 +410,15 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -413,21 +410,15 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
err_flag = 0; err_flag = 0;
r_offset = 0; r_offset = 0;
unsigned char bw_scaling =1; uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
switch (frame_parms->N_RB_UL) {
case 106: if (N_RB != 273) {
bw_scaling =2; a_segments = a_segments*N_RB;
break; a_segments = a_segments/273;
}
default:
bw_scaling =1;
break;
}
if (harq_process->C > MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling) { if (harq_process->C > a_segments) {
LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling); LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
return (ulsch->max_ldpc_iterations + 1); return (ulsch->max_ldpc_iterations + 1);
} }
#ifdef DEBUG_ULSCH_DECODING #ifdef DEBUG_ULSCH_DECODING
......
...@@ -103,25 +103,14 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint ...@@ -103,25 +103,14 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
NR_UE_DLSCH_t *dlsch; NR_UE_DLSCH_t *dlsch;
uint8_t exit_flag = 0,i,r; uint8_t exit_flag = 0,i,r;
unsigned char bw_scaling =1; uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
switch (N_RB_DL) { if (N_RB != 273) {
case 6: a_segments = a_segments*N_RB;
bw_scaling =16; a_segments = a_segments/273;
break; }
case 25: uint16_t dlsch_bytes = a_segments*1056; // allocated bytes per segment
bw_scaling =4;
break;
case 50:
bw_scaling =2;
break;
default:
bw_scaling =1;
break;
}
dlsch = (NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t)); dlsch = (NR_UE_DLSCH_t *)malloc16(sizeof(NR_UE_DLSCH_t));
...@@ -140,15 +129,15 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint ...@@ -140,15 +129,15 @@ NR_UE_DLSCH_t *new_nr_ue_dlsch(uint8_t Kmimo,uint8_t Mdlharq,uint32_t Nsoft,uint
if (dlsch->harq_processes[i]) { if (dlsch->harq_processes[i]) {
memset(dlsch->harq_processes[i],0,sizeof(NR_DL_UE_HARQ_t)); memset(dlsch->harq_processes[i],0,sizeof(NR_DL_UE_HARQ_t));
dlsch->harq_processes[i]->first_tx=1; dlsch->harq_processes[i]->first_tx=1;
dlsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); dlsch->harq_processes[i]->b = (uint8_t*)malloc16(dlsch_bytes);
if (dlsch->harq_processes[i]->b) if (dlsch->harq_processes[i]->b)
memset(dlsch->harq_processes[i]->b,0,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling); memset(dlsch->harq_processes[i]->b,0,dlsch_bytes);
else else
exit_flag=3; exit_flag=3;
if (abstraction_flag == 0) { if (abstraction_flag == 0) {
for (r=0; r<MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling; r++) { for (r=0; r<a_segments; r++) {
dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem(); dlsch->harq_processes[i]->p_nrLDPC_procBuf[r] = nrLDPC_init_mem();
dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(1056); dlsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(1056);
...@@ -387,20 +376,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -387,20 +376,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
err_flag = 0; err_flag = 0;
r_offset = 0; r_offset = 0;
unsigned char bw_scaling =1; uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
switch (frame_parms->N_RB_DL) { if (N_RB != 273) {
case 106: a_segments = a_segments*N_RB;
bw_scaling =2; a_segments = a_segments/273;
break; }
default:
bw_scaling =1;
break;
}
if (harq_process->C > MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling) { if (harq_process->C > a_segments) {
LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling); LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
return((1+dlsch->max_ldpc_iterations)); return((1+dlsch->max_ldpc_iterations));
} }
...@@ -918,20 +902,15 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -918,20 +902,15 @@ uint32_t nr_dlsch_decoding_mthread(PHY_VARS_NR_UE *phy_vars_ue,
err_flag = 0; err_flag = 0;
r_offset = 0; r_offset = 0;
unsigned char bw_scaling =1; uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
switch (frame_parms->N_RB_DL) { if (N_RB != 273) {
case 106: a_segments = a_segments*N_RB;
bw_scaling =2; a_segments = a_segments/273;
break; }
default: if (harq_process->C > a_segments) {
bw_scaling =1; LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
break;
}
if (harq_process->C > MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling) {
LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling);
return((1+dlsch->max_ldpc_iterations)); return((1+dlsch->max_ldpc_iterations));
} }
#ifdef DEBUG_DLSCH_DECODING #ifdef DEBUG_DLSCH_DECODING
...@@ -1497,20 +1476,15 @@ void *nr_dlsch_decoding_process(void *arg) ...@@ -1497,20 +1476,15 @@ void *nr_dlsch_decoding_process(void *arg)
//r_offset = 0; //r_offset = 0;
/* /*
unsigned char bw_scaling =1; uint16_t a_segments = MAX_NUM_NR_DLSCH_SEGMENTS; //number of segments to be allocated
switch (frame_parms->N_RB_DL) { if (N_RB != 273) {
case 106: a_segments = a_segments*N_RB;
bw_scaling =2; a_segments = a_segments/273;
break; }
default:
bw_scaling =1;
break;
}
if (harq_process->C > MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling) { if (harq_process->C > a_segments) {
LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,MAX_NUM_NR_DLSCH_SEGMENTS/bw_scaling); LOG_E(PHY,"Illegal harq_process->C %d > %d\n",harq_process->C,a_segments);
return((1+dlsch->max_ldpc_iterations)); return((1+dlsch->max_ldpc_iterations));
}*/ }*/
#ifdef DEBUG_DLSCH_DECODING #ifdef DEBUG_DLSCH_DECODING
......
...@@ -92,18 +92,14 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, ...@@ -92,18 +92,14 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL,
{ {
NR_UE_ULSCH_t *ulsch; NR_UE_ULSCH_t *ulsch;
unsigned char exit_flag = 0,i,r; unsigned char exit_flag = 0,i,r;
unsigned char bw_scaling =1; uint16_t a_segments = MAX_NUM_NR_ULSCH_SEGMENTS; //number of segments to be allocated
switch (N_RB_UL) { if (N_RB != 273) {
a_segments = a_segments*N_RB;
a_segments = a_segments/273;
}
case 106: uint16_t ulsch_bytes = a_segments*1056; // allocated bytes per segment
bw_scaling =2;
break;
default:
bw_scaling =1;
break;
}
ulsch = (NR_UE_ULSCH_t *)malloc16(sizeof(NR_UE_ULSCH_t)); ulsch = (NR_UE_ULSCH_t *)malloc16(sizeof(NR_UE_ULSCH_t));
...@@ -123,25 +119,25 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL, ...@@ -123,25 +119,25 @@ NR_UE_ULSCH_t *new_nr_ue_ulsch(unsigned char N_RB_UL,
// printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]); // printf("ulsch->harq_processes[%d] %p\n",i,ulsch->harq_processes[i]);
if (ulsch->harq_processes[i]) { if (ulsch->harq_processes[i]) {
memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t)); memset(ulsch->harq_processes[i], 0, sizeof(NR_UL_UE_HARQ_t));
ulsch->harq_processes[i]->b = (uint8_t*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); ulsch->harq_processes[i]->b = (uint8_t*)malloc16(ulsch_bytes);
ulsch->harq_processes[i]->a = (unsigned char*)malloc16(MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); ulsch->harq_processes[i]->a = (unsigned char*)malloc16(ulsch_bytes);
if (ulsch->harq_processes[i]->a) { if (ulsch->harq_processes[i]->a) {
bzero(ulsch->harq_processes[i]->a,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); bzero(ulsch->harq_processes[i]->a,ulsch_bytes);
} else { } else {
printf("Can't allocate PDU\n"); printf("Can't allocate PDU\n");
exit_flag=1; exit_flag=1;
} }
if (ulsch->harq_processes[i]->b) if (ulsch->harq_processes[i]->b)
bzero(ulsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); bzero(ulsch->harq_processes[i]->b,ulsch_bytes);
else { else {
LOG_E(PHY,"Can't get b\n"); LOG_E(PHY,"Can't get b\n");
exit_flag=1; exit_flag=1;
} }
if (abstraction_flag==0) { if (abstraction_flag==0) {
for (r=0; r<MAX_NUM_NR_ULSCH_SEGMENTS/bw_scaling; r++) { for (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
ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448); ulsch->harq_processes[i]->c[r] = (uint8_t*)malloc16(8448);
ulsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output ulsch->harq_processes[i]->d[r] = (uint8_t*)malloc16(68*384); //max size for coded output
......
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