Commit d351060b authored by Francesco Mani's avatar Francesco Mani

making segmentation BG dependent

parent ef850d12
...@@ -454,7 +454,8 @@ int32_t nr_segmentation(unsigned char *input_buffer, ...@@ -454,7 +454,8 @@ int32_t nr_segmentation(unsigned char *input_buffer,
unsigned int *C, unsigned int *C,
unsigned int *K, unsigned int *K,
unsigned int *Zout, unsigned int *Zout,
unsigned int *F); unsigned int *F,
uint8_t BG);
uint32_t nr_compute_tbs(uint8_t mcs, uint32_t nr_compute_tbs(uint8_t mcs,
uint16_t nb_rb, uint16_t nb_rb,
......
...@@ -35,20 +35,26 @@ int32_t nr_segmentation(unsigned char *input_buffer, ...@@ -35,20 +35,26 @@ int32_t nr_segmentation(unsigned char *input_buffer,
unsigned int *C, unsigned int *C,
unsigned int *K, unsigned int *K,
unsigned int *Zout, // [hna] Zout is Zc unsigned int *Zout, // [hna] Zout is Zc
unsigned int *F) unsigned int *F,
uint8_t BG)
{ {
unsigned int L,Bprime,Bprime_by_C,Z,r,Kb,k,s,crc,Kprime; unsigned int L,Bprime,Z,r,Kcb,Kb,k,s,crc,Kprime;
if (B<=8448) { if (BG==1)
Kcb=8448;
else
Kcb=3840;
if (B<=Kcb) {
L=0; L=0;
*C=1; *C=1;
Bprime=B; Bprime=B;
} else { } else {
L=24; L=24;
*C = B/(8448-L); *C = B/(Kcb-L);
if ((8448-L)*(*C) < B) if ((Kcb-L)*(*C) < B)
*C=*C+1; *C=*C+1;
Bprime = B+((*C)*L); Bprime = B+((*C)*L);
...@@ -63,27 +69,31 @@ int32_t nr_segmentation(unsigned char *input_buffer, ...@@ -63,27 +69,31 @@ int32_t nr_segmentation(unsigned char *input_buffer,
} }
// Find K+ // Find K+
Bprime_by_C = Bprime/(*C); Kprime = Bprime/(*C);
if (Bprime <=192) {
Kb = 6; if (BG==1)
} else if (Bprime <=560) { Kb = 22;
Kb = 8; else {
} else if (Bprime <=640) { if (B > 640) {
Kb = 9; Kb = 10;
} else if (Bprime <=3840) { } else if (B > 560) {
Kb = 10;; Kb = 9;
} else { } else if (B > 192) {
Kb = 22; Kb = 8;
}
else {
Kb = 6;
}
} }
if ((Bprime_by_C%Kb) > 0) if ((Kprime%Kb) > 0)
Z = (Bprime_by_C/Kb)+1; Z = (Kprime/Kb)+1;
else else
Z = (Bprime_by_C/Kb); Z = (Kprime/Kb);
#ifdef DEBUG_SEGMENTATION #ifdef DEBUG_SEGMENTATION
printf("nr segmetation B %d Bprime %d Bprime_by_C %d z %d \n", B, Bprime, Bprime_by_C, Z); printf("nr segmetation B %d Bprime %d Kprime %d z %d \n", B, Bprime, Kprime, Z);
#endif #endif
if (Z <= 2) { if (Z <= 2) {
...@@ -128,10 +138,15 @@ else ...@@ -128,10 +138,15 @@ else
//msg("nr_segmentation.c: Illegal codeword size !!!\n"); //msg("nr_segmentation.c: Illegal codeword size !!!\n");
return -1; return -1;
} }
*Zout = *K; *Zout = *K;
*K = *K*Kb;
*F = ((*K) - Bprime_by_C); if(BG==1)
*K = *K*22;
else
*K = *K*10;
*F = ((*K) - Kprime);
#ifdef DEBUG_SEGMENTATION #ifdef DEBUG_SEGMENTATION
printf("final nr seg output Z %d K %d F %d \n", *Zout, *K, *F); printf("final nr seg output Z %d K %d F %d \n", *Zout, *K, *F);
...@@ -145,7 +160,6 @@ else ...@@ -145,7 +160,6 @@ else
for (r=0; r<*C; r++) { for (r=0; r<*C; r++) {
k = 0; k = 0;
Kprime = Bprime_by_C;
while (k<((Kprime - L)>>3)) { while (k<((Kprime - L)>>3)) {
output_buffers[r][k] = input_buffer[s]; output_buffers[r][k] = input_buffer[s];
...@@ -154,6 +168,13 @@ else ...@@ -154,6 +168,13 @@ else
s++; s++;
} }
if (*C > 1) { // add CRC
crc = crc24b(output_buffers[r],Kprime-L)>>8;
output_buffers[r][(Kprime-L)>>3] = ((uint8_t*)&crc)[2];
output_buffers[r][1+((Kprime-L)>>3)] = ((uint8_t*)&crc)[1];
output_buffers[r][2+((Kprime-L)>>3)] = ((uint8_t*)&crc)[0];
}
if (*F>0) { if (*F>0) {
for (k=Kprime>>3; k<(*K)>>3; k++) { for (k=Kprime>>3; k<(*K)>>3; k++) {
output_buffers[r][k] = 0; output_buffers[r][k] = 0;
...@@ -161,12 +182,6 @@ else ...@@ -161,12 +182,6 @@ else
} }
} }
if (*C > 1) { // add CRC
crc = crc24b(output_buffers[r],Kprime-L)>>8;
output_buffers[r][(Kprime-L)>>3] = ((uint8_t*)&crc)[2];
output_buffers[r][1+((Kprime-L)>>3)] = ((uint8_t*)&crc)[1];
output_buffers[r][2+((Kprime-L)>>3)] = ((uint8_t*)&crc)[0];
}
} }
} }
......
...@@ -340,15 +340,6 @@ int nr_dlsch_encoding(unsigned char *a,int frame, ...@@ -340,15 +340,6 @@ int nr_dlsch_encoding(unsigned char *a,int frame,
memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4);
nr_segmentation(dlsch->harq_processes[harq_pid]->b,
dlsch->harq_processes[harq_pid]->c,
dlsch->harq_processes[harq_pid]->B,
&dlsch->harq_processes[harq_pid]->C,
&dlsch->harq_processes[harq_pid]->K,
pz, // [hna] pz is Zc
&dlsch->harq_processes[harq_pid]->F);
F = dlsch->harq_processes[harq_pid]->F;
Coderate = (float) A /(float) G; Coderate = (float) A /(float) G;
if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){
...@@ -358,6 +349,17 @@ int nr_dlsch_encoding(unsigned char *a,int frame, ...@@ -358,6 +349,17 @@ int nr_dlsch_encoding(unsigned char *a,int frame,
BG = 1; BG = 1;
} }
nr_segmentation(dlsch->harq_processes[harq_pid]->b,
dlsch->harq_processes[harq_pid]->c,
dlsch->harq_processes[harq_pid]->B,
&dlsch->harq_processes[harq_pid]->C,
&dlsch->harq_processes[harq_pid]->K,
pz, // [hna] pz is Zc
&dlsch->harq_processes[harq_pid]->F,
BG);
F = dlsch->harq_processes[harq_pid]->F;
Kr = dlsch->harq_processes[harq_pid]->K; Kr = dlsch->harq_processes[harq_pid]->K;
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
uint16_t Kr_bytes; uint16_t Kr_bytes;
......
...@@ -350,29 +350,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -350,29 +350,6 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
LOG_I(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb); LOG_I(PHY,"ULSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d nb_rb %d\n",harq_pid,A,G, mcs, n_layers, nb_symb_sch,nb_rb);
if (harq_process->round == 0) {
// This is a new packet, so compute quantities regarding segmentation
harq_process->B = A+24;
// [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F)
nr_segmentation(NULL,
NULL,
harq_process->B,
&harq_process->C,
&harq_process->K,
&harq_process->Z, // [hna] Z is Zc
&harq_process->F);
p_decParams->Z = harq_process->Z;
#ifdef DEBUG_ULSCH_DECODING
printf("ulsch decoding nr segmentation Z %d\n", p_decParams->Z);
if (!frame%100)
printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl);
#endif
}
Coderate = (float) A /(float) G; Coderate = (float) A /(float) G;
if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){ if ((A <=292) || ((A<=3824) && (Coderate <= 0.6667)) || Coderate <= 0.25){
...@@ -405,9 +382,29 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -405,9 +382,29 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
} }
} }
//printf("coderate %f kc %d \n", Coderate, kc); if (harq_process->round == 0) {
// This is a new packet, so compute quantities regarding segmentation
harq_process->B = A+24;
// [hna] Perform nr_segmenation with input and output set to NULL to calculate only (B, C, K, Z, F)
nr_segmentation(NULL,
NULL,
harq_process->B,
&harq_process->C,
&harq_process->K,
&harq_process->Z, // [hna] Z is Zc
&harq_process->F,
p_decParams->BG);
p_decParams->Z = harq_process->Z;
#ifdef DEBUG_ULSCH_DECODING
printf("ulsch decoding nr segmentation Z %d\n", p_decParams->Z);
if (!frame%100)
printf("K %d C %d Z %d nl %d \n", harq_process->K, harq_process->C, p_decParams->Z, harq_process->Nl);
#endif
}
p_decParams->numMaxIter = ulsch->max_ldpc_iterations; p_decParams->numMaxIter = ulsch->max_ldpc_iterations;
p_decParams->outMode= 0; p_decParams->outMode= 0;
......
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