Commit 8765bd9a authored by Hongzhi Wang's avatar Hongzhi Wang

adding nr_dlschsim for dlsch coding/decoding

parent 077905a6
...@@ -2534,8 +2534,13 @@ target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES}) ...@@ -2534,8 +2534,13 @@ target_link_libraries(polartest SIMU PHY PHY_NR PHY_COMMON m ${ATLAS_LIBRARIES})
add_executable(ldpctest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c) add_executable(ldpctest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c)
target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES}) target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES})
add_executable(nr_pbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c ) add_executable(nr_pbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c
target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB ${CONFIG_LIBRARIES} -Wl,--end-group m pthread dl ${ATLAS_LIBRARIES}) ${CONFIG_SOURCES})
target_link_libraries(nr_pbchsim -Wl,--start-group UTIL SIMU PHY PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB ${CONFIG_LIBRARIES} -Wl,--end-group m pthread dl rt ${CONFIG_LIBRARIES} ${ATLAS_LIBRARIES})
add_executable(nr_dlschsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/dlschsim.c
${CONFIG_SOURCES})
target_link_libraries(nr_dlschsim -Wl,--start-group UTIL SIMU PHY PHY_COMMON PHY_NR PHY_NR_UE SCHED_NR_LIB ${CONFIG_LIBRARIES} -Wl,--end-group m pthread dl rt ${CONFIG_LIBRARIES} ${ATLAS_LIBRARIES})
foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim) foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim prachsim syncsim)
......
...@@ -28,35 +28,8 @@ ...@@ -28,35 +28,8 @@
#define INDEX_MAX_TBS_TABLE (93) #define INDEX_MAX_TBS_TABLE (93)
//Table 5.1.3.1-1 //Table 5.1.3.1-1
uint16_t Mcsindextable1[29][3] = {{2,120,0.2344}, uint16_t Mcsindextable1[29][2] = {{2,120},{2,157},{2,193},{2,251},{2,308},{2,379},{2,449},{2,526},{2,602},{2,679},{4,340},{4,378},{4,434},{4,490},{4,553},{4,616},
{2,157,0.3066}, {4,658},{6,438},{6,466},{6,517},{6,567},{6,616},{6,666},{6,719},{6,772},{6,822},{6,873}, {6,910}, {6,948}};
{2,193,0.3770},
{2,251,0.4902},
{2,308,0.6016},
{2,379,0.7402},
{2,449,0.8770},
{2,526,1.0273},
{2,602,1.1758},
{2,679,1.3262},
{4,340,1.3281},
{4,378,1.4766},
{4,434,1.6953},
{4,490,1.9141},
{4,553,2.1602},
{4,616,2.4063},
{4,658,2.5703},
{6,438,2.5664},
{6,466,2.7305},
{6,517,3.0293},
{6,567,3.3223},
{6,616,3.6094},
{6,666,3.9023},
{6,719,4.2129},
{6,772,4.5234},
{6,822,4.8164},
{6,873,5.1152},
{6,910,5.3320},
{6,948,5.5547}};
//Table 5.1.2.2-2 //Table 5.1.2.2-2
uint16_t Tbstable_nr[INDEX_MAX_TBS_TABLE] = {24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,208,224,240,256,272,288,304,320,336,352,368,384,408,432,456,480,504,528,552,576,608,640,672,704,736,768,808,848,888,928,984,1032,1064,1128,1160,1192,1224,1256,1288,1320,1352,1416,1480,1544,1608,1672,1736,1800,1864,1928,2024,2088,2152,2216,2280,2408,2472,2536,2600,2664,2728,2792,2856,2976,3104,3240,3368,3496,3624,3752,3824}; uint16_t Tbstable_nr[INDEX_MAX_TBS_TABLE] = {24,32,40,48,56,64,72,80,88,96,104,112,120,128,136,144,152,160,168,176,184,192,208,224,240,256,272,288,304,320,336,352,368,384,408,432,456,480,504,528,552,576,608,640,672,704,736,768,808,848,888,928,984,1032,1064,1128,1160,1192,1224,1256,1288,1320,1352,1416,1480,1544,1608,1672,1736,1800,1864,1928,2024,2088,2152,2216,2280,2408,2472,2536,2600,2664,2728,2792,2856,2976,3104,3240,3368,3496,3624,3752,3824};
...@@ -67,8 +40,9 @@ uint32_t nr_compute_tbs(uint8_t mcs, ...@@ -67,8 +40,9 @@ uint32_t nr_compute_tbs(uint8_t mcs,
uint16_t length_dmrs, uint16_t length_dmrs,
uint8_t Nl) uint8_t Nl)
{ {
uint16_t nbp_re, nb_re, nb_dmrs_prb, nb_rb_oh, Ninfo,Np_info,n,Qm,R,C; uint16_t nbp_re, nb_re, nb_dmrs_prb, nb_rb_oh,Qm,R;
uint32_t nr_tbs; uint32_t nr_tbs=0;
double Ninfo,Np_info,n,C;
nb_rb_oh = 0; //set to 0 if not configured by higher layer nb_rb_oh = 0; //set to 0 if not configured by higher layer
Qm = Mcsindextable1[mcs][0]; Qm = Mcsindextable1[mcs][0];
...@@ -80,17 +54,17 @@ uint32_t nr_compute_tbs(uint8_t mcs, ...@@ -80,17 +54,17 @@ uint32_t nr_compute_tbs(uint8_t mcs,
nb_re = min(156, nbp_re) * nb_rb; nb_re = min(156, nbp_re) * nb_rb;
// Intermediate number of information bits // Intermediate number of information bits
Ninfo = (nb_re * R * Qm * Nl)/1024; Ninfo = (double)((nb_re * R * Qm * Nl)/1024);
//printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d\n", Ninfo, nbp_re, nb_re, Qm, R); //printf("Ninfo %d nbp_re %d nb_re %d Qm %d, R %d\n", Ninfo, nbp_re, nb_re, Qm, R);
if (Ninfo <=3824) { if (Ninfo <=3824) {
n = max(3, floor(log2(Ninfo)) - 6); n = max(3, floor(log2(Ninfo)) - 6);
Np_info = max(24, pow(n,2) * floor(Ninfo/pow(n,2))); Np_info = max(24, pow(2,n) * floor(Ninfo/pow(2,n)));
for (int i=0; i<INDEX_MAX_TBS_TABLE; i++) { for (int i=0; i<INDEX_MAX_TBS_TABLE; i++) {
if (Tbstable_nr[i] >= Np_info){ if ((double)Tbstable_nr[i] >= Np_info){
nr_tbs = Tbstable_nr[i]; nr_tbs = Tbstable_nr[i];
break; break;
} }
...@@ -98,19 +72,21 @@ uint32_t nr_compute_tbs(uint8_t mcs, ...@@ -98,19 +72,21 @@ uint32_t nr_compute_tbs(uint8_t mcs,
} }
else { else {
n = floor(log2(Ninfo-24)) - 5; n = floor(log2(Ninfo-24)) - 5;
Np_info = max(3840, pow(n,2) * round((Ninfo - 24)/pow(n,2))); Np_info = max(3840, pow(2,n) * round((Ninfo - 24)/pow(2,n)));
if (R <= 1024/4) { if (R <= 256) { //1/4
C = ceil( (Np_info + 24)/3816 ); C = ceil( (Np_info + 24)/3816 );
nr_tbs = 8 * C * ceil( (Np_info + 24)/(8*C) ) - 24; nr_tbs = (uint32_t)(8 * C * ceil( (Np_info + 24)/(8*C) ) - 24);
} }
else { else {
if (Np_info > 8424){ if (Np_info > 8424){
C = ceil( (Np_info + 24)/8424 ); C = ceil( (Np_info + 24)/8424 );
nr_tbs = 8 * C * ceil( (Np_info + 24)/(8*C) ) - 24; nr_tbs = (uint32_t)(8 * C * ceil( (Np_info + 24)/(8*C) ) - 24);
}
else {
nr_tbs = (uint32_t)(8 * ceil( (Np_info + 24)/8 ) - 24);
//printf("n %f Np_info %f pow %f ceil %f \n",n, Np_info,pow(2,6),ceil( (Np_info + 24)/8 ));
} }
else
nr_tbs = 8 * ceil( (Np_info + 24)/8 ) - 24;
} }
......
...@@ -54,7 +54,6 @@ void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f) ...@@ -54,7 +54,6 @@ void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f)
uint32_t EQm; uint32_t EQm;
EQm = E/Qm; EQm = E/Qm;
memset(e,0,E*sizeof(uint8_t));
for (int j = 0; j< EQm; j++){ for (int j = 0; j< EQm; j++){
for (int i = 0; i< Qm; i++){ for (int i = 0; i< Qm; i++){
...@@ -108,7 +107,7 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, ...@@ -108,7 +107,7 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm,
ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z; ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z;
#ifdef RM_DEBUG #ifdef RM_DEBUG
printf("nr_rate_matching: E %d, k0 %d \n",E,ind); printf("nr_rate_matching: E %d, k0 %d Cprime %d modcprime %d\n",E,ind, Cprime,((G/(Nl*Qm))%Cprime));
#endif #endif
e2 = e; e2 = e;
......
...@@ -53,5 +53,15 @@ uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx); ...@@ -53,5 +53,15 @@ uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx);
/** \brief Computes available bits G. /** \brief Computes available bits G.
@param nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs */ @param nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs */
uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs,uint8_t Qm); uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs,uint8_t Qm, uint8_t Nl);
int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
unsigned char *a,
uint16_t nb_symb_sch,
NR_gNB_DLSCH_t *dlsch,
int frame,
uint8_t subframe,
time_stats_t *rm_stats,
time_stats_t *te_stats,
time_stats_t *i_stats);
...@@ -162,10 +162,10 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t ...@@ -162,10 +162,10 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(unsigned char Kmimo,unsigned char Mdlharq,uint32_t
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_ULSCH_PAYLOAD_BYTES/bw_scaling); dlsch->harq_processes[i]->b = (unsigned char*)malloc16(MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
if (dlsch->harq_processes[i]->b) { if (dlsch->harq_processes[i]->b) {
bzero(dlsch->harq_processes[i]->b,MAX_NR_ULSCH_PAYLOAD_BYTES/bw_scaling); bzero(dlsch->harq_processes[i]->b,MAX_NR_DLSCH_PAYLOAD_BYTES/bw_scaling);
} else { } else {
printf("Can't get b\n"); printf("Can't get b\n");
exit_flag=1; exit_flag=1;
...@@ -245,7 +245,7 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch) ...@@ -245,7 +245,7 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
int nr_dlsch_encoding(PHY_VARS_gNB *gNB, int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
unsigned char *a, unsigned char *a,
uint8_t num_pdcch_symbols, uint16_t nb_symb_sch,
NR_gNB_DLSCH_t *dlsch, NR_gNB_DLSCH_t *dlsch,
int frame, int frame,
uint8_t subframe, uint8_t subframe,
...@@ -272,9 +272,10 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -272,9 +272,10 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
uint32_t E; uint32_t E;
uint8_t Ilbrm = 0; uint8_t Ilbrm = 0;
uint32_t Tbslbrm = 950984; //max tbs uint32_t Tbslbrm = 950984; //max tbs
uint16_t nb_symb_sch =2; //uint16_t nb_symb_sch =12;
uint8_t nb_re_dmrs = 6; uint8_t nb_re_dmrs = 6;
uint16_t length_dmrs = 1; uint16_t length_dmrs = 1;
uint8_t *channel_input[MAX_NUM_DLSCH_SEGMENTS]; //unsigned char
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN);
...@@ -284,9 +285,10 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -284,9 +285,10 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
A = dlsch->harq_processes[harq_pid]->TBS; A = dlsch->harq_processes[harq_pid]->TBS;
//printf("Encoder: A: %d frame.subframe %d.%d \n",A, frame,subframe); //printf("Encoder: A: %d frame.subframe %d.%d \n",A, frame,subframe);
mod_order = get_nr_Qm(dlsch->harq_processes[harq_pid]->mcs); mod_order = nr_get_Qm(dlsch->harq_processes[harq_pid]->mcs,1);
G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order); G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs,mod_order,dlsch->harq_processes[harq_pid]->Nl);
printf("dlsch coding A %d G %d mod_order %d\n", A,G, mod_order);
Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, dlsch->harq_processes[harq_pid]->Nl); Tbslbrm = nr_compute_tbs(28,nb_rb,frame_parms->symbols_per_slot,0,0, dlsch->harq_processes[harq_pid]->Nl);
...@@ -303,12 +305,12 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -303,12 +305,12 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
printf("\n"); printf("\n");
*/ */
// Add 24-bit crc (polynomial A) to payload // Add 24-bit crc (polynomial A) to payload
crc = crc24a(a, crc = crc24a(a,A)>>8;
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)]);
dlsch->harq_processes[harq_pid]->B = A+24; dlsch->harq_processes[harq_pid]->B = A+24;
// dlsch->harq_processes[harq_pid]->b = a; // dlsch->harq_processes[harq_pid]->b = a;
...@@ -330,37 +332,44 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -330,37 +332,44 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
BG = 2; BG = 2;
} }
//printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F);
Kr = dlsch->harq_processes[harq_pid]->K; Kr = dlsch->harq_processes[harq_pid]->K;
//Kr_bytes = Kr>>3; //Kr_bytes = Kr>>3;
start_meas(te_stats); start_meas(te_stats);
for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) { for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0]; d_tmp[r] = &dlsch->harq_processes[harq_pid]->d[r][0];
channel_input[r] = &dlsch->harq_processes[harq_pid]->d[r][0];
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
printf("Encoder: B %d F %d \n",dlsch->harq_processes[harq_pid]->B, dlsch->harq_processes[harq_pid]->F);
printf("start ldpc encoder segment %d/%d\n",r,dlsch->harq_processes[harq_pid]->C); printf("start ldpc encoder segment %d/%d\n",r,dlsch->harq_processes[harq_pid]->C);
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]); 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]);
/*for (int cnt =0 ; cnt < 22*(*pz); cnt ++){ for (int cnt =0 ; cnt < 22*(*pz)/8; cnt ++){
printf("%d ", dlsch->harq_processes[harq_pid]->c[r][cnt]); printf("%d ", dlsch->harq_processes[harq_pid]->c[r][cnt]);
}*/ }
printf("\n");
#endif #endif
//ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],&dlsch->harq_processes[harq_pid]->d[r][96],Kr,1,3,0); //&dlsch->harq_processes[harq_pid]->d[r][0] //channel_input[r]
//ldpc_encoder((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],&dlsch->harq_processes[harq_pid]->d[r][96],Kr,1,3); //ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],&dlsch->harq_processes[harq_pid]->d[r][0],Kr,1,3,0);
//ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][96],Kr,1,3,NULL,NULL,NULL,NULL); ldpc_encoder_orig((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],dlsch->harq_processes[harq_pid]->d[r],Kr,BG,0);
//ldpc_encoder((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],&dlsch->harq_processes[harq_pid]->d[r][0],Kr,1,3);
//ldpc_encoder_optim((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],(unsigned char*)&dlsch->harq_processes[harq_pid]->d[r][0],Kr,1,3,NULL,NULL,NULL,NULL);
} }
ldpc_encoder_optim_8seg(dlsch->harq_processes[harq_pid]->c,d_tmp,Kr,1,3,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL); //for (int i=0;i<68*384;i++)
stop_meas(te_stats); // printf("channel_input[%d]=%d\n",i,channel_input[i]);
/*printf("end ldpc encoder -- output\n");
printf("output %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->d[r][0], dlsch->harq_processes[harq_pid]->d[r][1], dlsch->harq_processes[harq_pid]->d[r][2],dlsch->harq_processes[harq_pid]->d[r][3], dlsch->harq_processes[harq_pid]->d[r][4]);
for (int cnt =0 ; cnt < 66*(*pz); cnt ++){ /*printf("output %d %d %d %d %d \n", dlsch->harq_processes[harq_pid]->d[0][0], dlsch->harq_processes[harq_pid]->d[0][1], dlsch->harq_processes[harq_pid]->d[r][2],dlsch->harq_processes[harq_pid]->d[0][3], dlsch->harq_processes[harq_pid]->d[0][4]);
printf("%d \n", dlsch->harq_processes[harq_pid]->d[r][cnt]); for (int cnt =0 ; cnt < 66*(*pz); cnt ++){
} printf("%d \n", dlsch->harq_processes[harq_pid]->d[0][cnt]);
printf("\n");*/ }
printf("\n");*/
//ldpc_encoder_optim_8seg(dlsch->harq_processes[harq_pid]->c,d_tmp,Kr,1,3,dlsch->harq_processes[harq_pid]->C,NULL,NULL,NULL,NULL);
stop_meas(te_stats);
//printf("end ldpc encoder -- output\n");
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4); write_output("enc_input0.m","enc_in0",&dlsch->harq_processes[harq_pid]->c[0][0],Kr_bytes,1,4);
...@@ -383,7 +392,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -383,7 +392,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
printf("rvidx in encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx); printf("rvidx in encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx);
#endif #endif
r_offset += nr_rate_matching_ldpc(Ilbrm, E = nr_rate_matching_ldpc(Ilbrm,
Tbslbrm, Tbslbrm,
BG, BG,
*pz, *pz,
...@@ -396,18 +405,25 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB, ...@@ -396,18 +405,25 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
dlsch->harq_processes[harq_pid]->Nl, dlsch->harq_processes[harq_pid]->Nl,
r); r);
#ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++)
printf("output ratematching e[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->e[i], r_offset);
#endif
stop_meas(rm_stats); stop_meas(rm_stats);
if (r==0) E=r_offset;
start_meas(i_stats); start_meas(i_stats);
nr_interleaving_ldpc(E, nr_interleaving_ldpc(E,
dlsch->harq_processes[harq_pid]->Qm, mod_order,
dlsch->harq_processes[harq_pid]->e+r_offset, dlsch->harq_processes[harq_pid]->e+r_offset,
dlsch->harq_processes[harq_pid]->f+r_offset); dlsch->harq_processes[harq_pid]->f+r_offset);
stop_meas(i_stats); stop_meas(i_stats);
r_offset += E;
#ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++)
printf("output interleaving f[%d]= %d r_offset %d\n", i,dlsch->harq_processes[harq_pid]->f[i+r*r_offset], r_offset);
#endif
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
if (r==dlsch->harq_processes[harq_pid]->C-1) if (r==dlsch->harq_processes[harq_pid]->C-1)
......
...@@ -80,8 +80,8 @@ uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx) { ...@@ -80,8 +80,8 @@ uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx) {
} }
} }
uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm) { uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16_t length_dmrs, uint8_t Qm, uint8_t Nl) {
uint32_t G; uint32_t G;
G = ((12*nb_symb_sch)-(nb_re_dmrs*length_dmrs))*nb_rb*Qm; G = ((12*nb_symb_sch)-(nb_re_dmrs*length_dmrs))*nb_rb*Qm*Nl;
return(G); return(G);
} }
...@@ -173,6 +173,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -173,6 +173,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
NR_UE_DLSCH_t *dlsch, NR_UE_DLSCH_t *dlsch,
NR_DL_UE_HARQ_t *harq_process, NR_DL_UE_HARQ_t *harq_process,
uint32_t frame, uint32_t frame,
uint16_t nb_symb_sch,
uint8_t nr_tti_rx, uint8_t nr_tti_rx,
uint8_t harq_pid, uint8_t harq_pid,
uint8_t is_crnti, uint8_t is_crnti,
...@@ -189,7 +190,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -189,7 +190,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
uint32_t ret,offset; uint32_t ret,offset;
int32_t no_iteration_ldpc; int32_t no_iteration_ldpc;
//short dummy_w[MAX_NUM_DLSCH_SEGMENTS][3*(8448+64)]; //short dummy_w[MAX_NUM_DLSCH_SEGMENTS][3*(8448+64)];
uint32_t r,r_offset=0,Kr,Kr_bytes,K_bytes_F,err_flag=0; uint32_t r,r_offset=0,Kr=8424,Kr_bytes,K_bytes_F,err_flag=0;
uint8_t crc_type; uint8_t crc_type;
t_nrLDPC_dec_params decParams; t_nrLDPC_dec_params decParams;
t_nrLDPC_dec_params* p_decParams = &decParams; t_nrLDPC_dec_params* p_decParams = &decParams;
...@@ -203,8 +204,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -203,8 +204,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
uint8_t kb, kc; uint8_t kb, kc;
uint8_t Ilbrm = 0; uint8_t Ilbrm = 0;
uint32_t Tbslbrm = 950984; uint32_t Tbslbrm = 950984;
uint16_t nb_rb = 106; //to update uint16_t nb_rb = 30; //to update
uint16_t nb_symb_sch = 2; //uint16_t nb_symb_sch = 12;
uint8_t nb_re_dmrs = 6; uint8_t nb_re_dmrs = 6;
uint16_t length_dmrs = 1; uint16_t length_dmrs = 1;
...@@ -214,6 +215,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -214,6 +215,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
__m128i *pv = (__m128i*)&z; __m128i *pv = (__m128i*)&z;
__m128i *pl = (__m128i*)&l; __m128i *pl = (__m128i*)&l;
//NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[0];
if (!dlsch_llr) { if (!dlsch_llr) {
printf("dlsch_decoding.c: NULL dlsch_llr pointer\n"); printf("dlsch_decoding.c: NULL dlsch_llr pointer\n");
return(dlsch->max_ldpc_iterations); return(dlsch->max_ldpc_iterations);
...@@ -229,15 +232,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -229,15 +232,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
return(dlsch->max_ldpc_iterations); return(dlsch->max_ldpc_iterations);
} }
if (nr_tti_rx> (10*frame_parms->ttis_per_subframe-1)) { /*if (nr_tti_rx> (10*frame_parms->ttis_per_subframe-1)) {
printf("dlsch_decoding.c: Illegal subframe index %d\n",nr_tti_rx); printf("dlsch_decoding.c: Illegal subframe index %d\n",nr_tti_rx);
return(dlsch->max_ldpc_iterations); return(dlsch->max_ldpc_iterations);
} }*/
if (harq_process->harq_ack.ack != 2) { /*if (harq_process->harq_ack.ack != 2) {
LOG_D(PHY, "[UE %d] DLSCH @ SF%d : ACK bit is %d instead of DTX even before PDSCH is decoded!\n", LOG_D(PHY, "[UE %d] DLSCH @ SF%d : ACK bit is %d instead of DTX even before PDSCH is decoded!\n",
phy_vars_ue->Mod_id, nr_tti_rx, harq_process->harq_ack.ack); phy_vars_ue->Mod_id, nr_tti_rx, harq_process->harq_ack.ack);
} }*/
// nb_rb = dlsch->nb_rb; // nb_rb = dlsch->nb_rb;
...@@ -254,6 +257,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -254,6 +257,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
} }
*/ */
nb_rb = harq_process->nb_rb;
harq_process->trials[harq_process->round]++; harq_process->trials[harq_process->round]++;
harq_process->TBS = nr_compute_tbs(harq_process->mcs,nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs, harq_process->Nl); harq_process->TBS = nr_compute_tbs(harq_process->mcs,nb_rb,nb_symb_sch,nb_re_dmrs,length_dmrs, harq_process->Nl);
...@@ -261,11 +266,10 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -261,11 +266,10 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
A = harq_process->TBS; A = harq_process->TBS;
ret = dlsch->max_ldpc_iterations; ret = dlsch->max_ldpc_iterations;
harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq_process->Qm); harq_process->G = nr_get_G(nb_rb, nb_symb_sch, nb_re_dmrs, length_dmrs, harq_process->Qm,harq_process->Nl);
G = harq_process->G; G = harq_process->G;
//get_G(frame_parms,nb_rb,dlsch->rb_alloc,mod_order,num_pdcch_symbols,phy_vars_ue->frame,subframe);
// printf("DLSCH Decoding, harq_pid %d Ndi %d\n",harq_pid,harq_process->Ndi); //printf("DLSCH Decoding, harq_pid %d TBS %d G %d mcs %d Nl %d nb_symb_sch %d \n",harq_pid,A,G, harq_process->mcs, harq_process->Nl, nb_symb_sch);
if (harq_process->round == 0) { if (harq_process->round == 0) {
// This is a new packet, so compute quantities regarding segmentation // This is a new packet, so compute quantities regarding segmentation
...@@ -278,10 +282,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -278,10 +282,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
&harq_process->Z, &harq_process->Z,
&harq_process->F); &harq_process->F);
p_decParams->Z = harq_process->Z; p_decParams->Z = harq_process->Z;
//printf("dlsch 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);
#ifdef DEBUG_DLSCH_DECODING
printf("dlsch 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
} }
kb = harq_process->K/harq_process->Z; kb = harq_process->K/harq_process->Z;
...@@ -322,7 +328,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -322,7 +328,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
return((1+dlsch->max_ldpc_iterations)); return((1+dlsch->max_ldpc_iterations));
} }
#ifdef DEBUG_DLSCH_DECODING #ifdef DEBUG_DLSCH_DECODING
printf("Segmentation: C %d, Cminus %d, Kminus %d, K %d\n",harq_process->C,harq_process->Cminus,harq_process->Kminus,harq_process->K); printf("Segmentation: C %d, K %d\n",harq_process->C,harq_process->K);
#endif #endif
opp_enabled=1; opp_enabled=1;
...@@ -336,6 +342,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -336,6 +342,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
for (r=0; r<harq_process->C; r++) { for (r=0; r<harq_process->C; r++) {
printf("start rx segment %d\n",r);
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(dlsch_rate_unmatching_stats); start_meas(dlsch_rate_unmatching_stats);
#endif #endif
...@@ -380,11 +388,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -380,11 +388,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
} }
r_offset += E; r_offset += E;
/* //for (int i =0; i<16; i++)
printf("Subblock deinterleaving, d %p w %p\n", // printf("rx output ratematching w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset);
harq_process->d[r],
harq_process->w);
*/
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(dlsch_deinterleaving_stats); start_meas(dlsch_deinterleaving_stats);
#endif #endif
...@@ -393,6 +399,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -393,6 +399,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
harq_process->d[r], harq_process->d[r],
harq_process->w[r]); harq_process->w[r]);
//for (int i =0; i<16; i++)
// printf("rx output interleaving d[%d]= %d r_offset %d\n", i,harq_process->d[r][i], r_offset);
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
stop_meas(dlsch_deinterleaving_stats); stop_meas(dlsch_deinterleaving_stats);
#endif #endif
...@@ -433,23 +442,20 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -433,23 +442,20 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
//LOG_E(PHY,"AbsSubframe %d.%d Start turbo segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A); //LOG_E(PHY,"AbsSubframe %d.%d Start turbo segment %d/%d A %d ",frame%1024,nr_tti_rx,r,harq_process->C-1, A);
//printf("harq process dr iteration %d\n", p_decParams->numMaxIter); //printf("harq process dr iteration %d\n", p_decParams->numMaxIter);
//66*p_decParams->Z
//if (A < 1000){
for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){ for (int cnt =0; cnt < (kc-2)*p_decParams->Z; cnt++){
inv_d[cnt] = (-1)*harq_process->d[r][cnt]; inv_d[cnt] = (1)*harq_process->d[r][cnt];
} }
//}
/*for (int cnt =0; cnt < 8; cnt++){ /*for (int cnt =0; cnt < 16; cnt++){
printf("dr %d inv_d %d \n", harq_process->d[r][96+cnt], inv_d[cnt]); printf("dr %d inv_d %d \n", harq_process->d[r][cnt], inv_d[cnt]);
} }
printf(" \n");*/ printf(" \n");
/*printf("end dr \n"); printf("end dr \n");
for (int cnt =(50*p_decParams->Z-16) ; cnt < 50*p_decParams->Z; cnt++){ for (int cnt =(50*p_decParams->Z-16) ; cnt < 50*p_decParams->Z; cnt++){
printf("%d ", harq_process->d[r][96+cnt]); printf("%d ", harq_process->d[r][cnt]);
} }
printf(" \n");*/ printf(" \n");*/
...@@ -457,12 +463,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue, ...@@ -457,12 +463,12 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
//memset(pl,0,2*p_decParams->Z*sizeof(int8_t)); //memset(pl,0,2*p_decParams->Z*sizeof(int8_t));
memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t)); memset((pv+K_bytes_F),127,harq_process->F*sizeof(int16_t));
for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F; i++, j++) for (i=((2*p_decParams->Z)>>3), j = 0; i < K_bytes_F+((2*p_decParams->Z)>>3); i++, j++)
{ {
pv[i]= _mm_loadu_si128((__m128i*)(&