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})
add_executable(ldpctest ${OPENAIR1_DIR}/PHY/CODING/TESTBENCH/ldpctest.c)
target_link_libraries(ldpctest SIMU PHY PHY_NR m ${ATLAS_LIBRARIES})
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})
add_executable(nr_pbchsim ${OPENAIR1_DIR}/SIMULATION/NR_PHY/pbchsim.c
${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)
......
......@@ -28,35 +28,8 @@
#define INDEX_MAX_TBS_TABLE (93)
//Table 5.1.3.1-1
uint16_t Mcsindextable1[29][3] = {{2,120,0.2344},
{2,157,0.3066},
{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}};
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},
{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}};
//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};
......@@ -67,8 +40,9 @@ uint32_t nr_compute_tbs(uint8_t mcs,
uint16_t length_dmrs,
uint8_t Nl)
{
uint16_t nbp_re, nb_re, nb_dmrs_prb, nb_rb_oh, Ninfo,Np_info,n,Qm,R,C;
uint32_t nr_tbs;
uint16_t nbp_re, nb_re, nb_dmrs_prb, nb_rb_oh,Qm,R;
uint32_t nr_tbs=0;
double Ninfo,Np_info,n,C;
nb_rb_oh = 0; //set to 0 if not configured by higher layer
Qm = Mcsindextable1[mcs][0];
......@@ -80,17 +54,17 @@ uint32_t nr_compute_tbs(uint8_t mcs,
nb_re = min(156, nbp_re) * nb_rb;
// 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);
if (Ninfo <=3824) {
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++) {
if (Tbstable_nr[i] >= Np_info){
if ((double)Tbstable_nr[i] >= Np_info){
nr_tbs = Tbstable_nr[i];
break;
}
......@@ -98,19 +72,21 @@ uint32_t nr_compute_tbs(uint8_t mcs,
}
else {
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 );
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 {
if (Np_info > 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)
uint32_t EQm;
EQm = E/Qm;
memset(e,0,E*sizeof(uint8_t));
for (int j = 0; j< EQm; j++){
for (int i = 0; i< Qm; i++){
......@@ -108,7 +107,7 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm,
ind = (index_k0[BG-1][rvidx]*Ncb/N)*Z;
#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
e2 = e;
......
......@@ -53,5 +53,15 @@ uint32_t nr_get_code_rate(uint8_t Imcs, uint8_t table_idx);
/** \brief Computes available bits G.
@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
if (dlsch->harq_processes[i]) {
bzero(dlsch->harq_processes[i],sizeof(NR_DL_gNB_HARQ_t));
// 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) {
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 {
printf("Can't get b\n");
exit_flag=1;
......@@ -245,7 +245,7 @@ void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch)
int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
unsigned char *a,
uint8_t num_pdcch_symbols,
uint16_t nb_symb_sch,
NR_gNB_DLSCH_t *dlsch,
int frame,
uint8_t subframe,
......@@ -272,9 +272,10 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
uint32_t E;
uint8_t Ilbrm = 0;
uint32_t Tbslbrm = 950984; //max tbs
uint16_t nb_symb_sch =2;
//uint16_t nb_symb_sch =12;
uint8_t nb_re_dmrs = 6;
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);
......@@ -284,9 +285,10 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
A = dlsch->harq_processes[harq_pid]->TBS;
//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);
......@@ -303,12 +305,12 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
printf("\n");
*/
// 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[1+(A>>3)] = ((uint8_t*)&crc)[1];
a[2+(A>>3)] = ((uint8_t*)&crc)[0];
//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;
......@@ -330,37 +332,44 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
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_bytes = Kr>>3;
start_meas(te_stats);
for (r=0; r<dlsch->harq_processes[harq_pid]->C; r++) {
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
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("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("\n");
#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);
//ldpc_encoder((unsigned char*)dlsch->harq_processes[harq_pid]->c[r],&dlsch->harq_processes[harq_pid]->d[r][96],Kr,1,3);
//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);
//&dlsch->harq_processes[harq_pid]->d[r][0] //channel_input[r]
//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_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);
stop_meas(te_stats);
/*printf("end ldpc encoder -- output\n");
//for (int i=0;i<68*384;i++)
// printf("channel_input[%d]=%d\n",i,channel_input[i]);
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("%d \n", dlsch->harq_processes[harq_pid]->d[r][cnt]);
}
printf("\n");*/
/*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]);
for (int cnt =0 ; cnt < 66*(*pz); cnt ++){
printf("%d \n", dlsch->harq_processes[harq_pid]->d[0][cnt]);
}
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
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,
printf("rvidx in encoding = %d\n", dlsch->harq_processes[harq_pid]->rvidx);
#endif
r_offset += nr_rate_matching_ldpc(Ilbrm,
E = nr_rate_matching_ldpc(Ilbrm,
Tbslbrm,
BG,
*pz,
......@@ -396,18 +405,25 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
dlsch->harq_processes[harq_pid]->Nl,
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);
if (r==0) E=r_offset;
start_meas(i_stats);
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]->f+r_offset);
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
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) {
}
}
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;
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);
}
......@@ -173,6 +173,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
NR_UE_DLSCH_t *dlsch,
NR_DL_UE_HARQ_t *harq_process,
uint32_t frame,
uint16_t nb_symb_sch,
uint8_t nr_tti_rx,
uint8_t harq_pid,
uint8_t is_crnti,
......@@ -189,7 +190,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
uint32_t ret,offset;
int32_t no_iteration_ldpc;
//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;
t_nrLDPC_dec_params decParams;
t_nrLDPC_dec_params* p_decParams = &decParams;
......@@ -203,8 +204,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
uint8_t kb, kc;
uint8_t Ilbrm = 0;
uint32_t Tbslbrm = 950984;
uint16_t nb_rb = 106; //to update
uint16_t nb_symb_sch = 2;
uint16_t nb_rb = 30; //to update
//uint16_t nb_symb_sch = 12;
uint8_t nb_re_dmrs = 6;
uint16_t length_dmrs = 1;
......@@ -214,6 +215,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
__m128i *pv = (__m128i*)&z;
__m128i *pl = (__m128i*)&l;
//NR_DL_UE_HARQ_t *harq_process = dlsch->harq_processes[0];
if (!dlsch_llr) {
printf("dlsch_decoding.c: NULL dlsch_llr pointer\n");
return(dlsch->max_ldpc_iterations);
......@@ -229,15 +232,15 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
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);
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",
phy_vars_ue->Mod_id, nr_tti_rx, harq_process->harq_ack.ack);
}
}*/
// nb_rb = dlsch->nb_rb;
......@@ -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->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,
A = harq_process->TBS;
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;
//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) {
// 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,
&harq_process->Z,
&harq_process->F);
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;
......@@ -322,7 +328,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
return((1+dlsch->max_ldpc_iterations));
}
#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
opp_enabled=1;
......@@ -336,6 +342,8 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
for (r=0; r<harq_process->C; r++) {
printf("start rx segment %d\n",r);
#if UE_TIMING_TRACE
start_meas(dlsch_rate_unmatching_stats);
#endif
......@@ -380,11 +388,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
}
r_offset += E;
/*
printf("Subblock deinterleaving, d %p w %p\n",
harq_process->d[r],
harq_process->w);
*/
//for (int i =0; i<16; i++)
// printf("rx output ratematching w[%d]= %d r_offset %d\n", i,harq_process->w[r][i], r_offset);
#if UE_TIMING_TRACE
start_meas(dlsch_deinterleaving_stats);
#endif
......@@ -393,6 +399,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
harq_process->d[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
stop_meas(dlsch_deinterleaving_stats);
#endif
......@@ -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);
//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++){
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++){
printf("dr %d inv_d %d \n", harq_process->d[r][96+cnt], inv_d[cnt]);
/*for (int cnt =0; cnt < 16; 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++){
printf("%d ", harq_process->d[r][96+cnt]);
printf("%d ", harq_process->d[r][cnt]);
}
printf(" \n");*/
......@@ -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((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*)(&inv_d[8*j]));
}
for (i=Kr_bytes, j = K_bytes_F; i < ((kc*p_decParams->Z)>>3); i++, j++)
for (i=Kr_bytes+((2*p_decParams->Z)>>3),j=Kr_bytes; i < ((kc*p_decParams->Z)>>3); i++, j++)
{
pv[i]= _mm_loadu_si128((__m128i*)(&inv_d[8*j]));
}
......@@ -497,9 +503,9 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
else {
ret=2;
}
if (!nb_total_decod%10000){
//if (!nb_total_decod%10000){
printf("Error number of iteration LPDC %d %ld/%ld \n", no_iteration_ldpc, nb_error_decod,nb_total_decod);fflush(stdout);
}
//}
//else
//printf("OK number of iteration LPDC %d\n", no_iteration_ldpc);
......@@ -512,7 +518,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
#ifdef DEBUG_DLSCH_DECODING
printf("output decoder %d %d %d %d %d \n", harq_process->c[r][0], harq_process->c[r][1], harq_process->c[r][2],harq_process->c[r][3], harq_process->c[r][4]);
printf("no_iterations_ldpc %d (ret %d)\n",no_iteration_ldpc,ret);
write_output("dec_output.m","dec0",harq_process->c[0],Kr_bytes,1,4);
//write_output("dec_output.m","dec0",harq_process->c[0],Kr_bytes,1,4);
#endif
......
......@@ -999,6 +999,7 @@ uint32_t nr_dlsch_decoding(PHY_VARS_NR_UE *phy_vars_ue,
NR_UE_DLSCH_t *dlsch,
NR_DL_UE_HARQ_t *harq_process,
uint32_t frame,
uint16_t nb_symb_sch,
uint8_t nr_tti_rx,
uint8_t harq_pid,
uint8_t is_crnti,
......
......@@ -57,7 +57,7 @@
*
*********************************************************************/
#define DBG_PSS_NR
//#define DBG_PSS_NR
void *get_idft(int ofdm_symbol_size)
{
......
......@@ -5761,7 +5761,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN
stop_meas(&ue->pdsch_procedures_stat[ue->current_thread_id[nr_tti_rx]]);
start_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[nr_tti_rx]]);
#endif
/*ue_dlsch_procedures(ue,
nr_ue_dlsch_procedures(ue,
proc,
eNB_id,
PDSCH,
......@@ -5769,7 +5769,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eN
ue->dlsch[ue->current_thread_id[nr_tti_rx]][eNB_id][1],
&ue->dlsch_errors[eNB_id],
mode,
abstraction_flag);*/
abstraction_flag);
#if UE_TIMING_TRACE
stop_meas(&ue->dlsch_procedures_stat[ue->current_thread_id[nr_tti_rx]]);
#if DISABLE_LOG_X
......
This diff is collapsed.
......@@ -726,7 +726,7 @@ void print_opp_meas(void) {
print_meas(&softmodem_stats_rx_sf,"[gNB][total_phy_proc_rx]",NULL,NULL);
}
}
/*
void free_transport(PHY_VARS_gNB *gNB)
{
int i;
......@@ -736,20 +736,20 @@ void free_transport(PHY_VARS_gNB *gNB)
LOG_I(PHY, "Freeing Transport Channel Buffers for DLSCH, UE %d\n",i);
for (j=0; j<2; j++) free_gNB_dlsch(gNB->dlsch[i][j]);
LOG_I(PHY, "Freeing Transport Channel Buffer for ULSCH, UE %d\n",i);
free_gNB_ulsch(gNB->ulsch[1+i]);
//LOG_I(PHY, "Freeing Transport Channel Buffer for ULSCH, UE %d\n",i);
//free_gNB_ulsch(gNB->ulsch[1+i]);
}
free_gNB_ulsch(gNB->ulsch[0]);
}*/
//free_gNB_ulsch(gNB->ulsch[0]);
}
/*
void init_transport(PHY_VARS_gNB *gNB) {
void init_nr_transport(PHY_VARS_gNB *gNB) {
int i;
int j;
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
LOG_I(PHY, "Initialise transport\n");
LOG_I(PHY, "Initialise nr transport\n");
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
LOG_I(PHY,"Allocating Transport Channel Buffers for DLSCH, UE %d\n",i);
......@@ -764,8 +764,8 @@ void init_transport(PHY_VARS_gNB *gNB) {
}
}
LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i);
gNB->ulsch[1+i] = new_gNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0);
//LOG_I(PHY,"Allocating Transport Channel Buffer for ULSCH, UE %d\n",i);
//gNB->ulsch[1+i] = new_gNB_ulsch(MAX_TURBO_ITERATIONS,fp->N_RB_UL, 0);
if (!gNB->ulsch[1+i]) {
LOG_E(PHY,"Can't get gNB ulsch structures\n");
......@@ -774,10 +774,10 @@ void init_transport(PHY_VARS_gNB *gNB) {
// this is the transmission mode for the signalling channels
// this will be overwritten with the real transmission mode by the RRC once the UE is connected
gNB->transmission_mode[i] = fp->nb_antenna_ports_gNB==1 ? 1 : 2;
//gNB->transmission_mode[i] = fp->nb_antenna_ports_gNB==1 ? 1 : 2;
}
// ULSCH for RA
gNB->ulsch[0] = new_gNB_ulsch(MAX_TURBO_ITERATIONS, fp->N_RB_UL, 0);
//gNB->ulsch[0] = new_gNB_ulsch(MAX_TURBO_ITERATIONS, fp->N_RB_UL, 0);
if (!gNB->ulsch[0]) {
LOG_E(PHY,"Can't get gNB ulsch structures\n");
......@@ -804,9 +804,9 @@ void init_transport(PHY_VARS_gNB *gNB) {
gNB->check_for_SUMIMO_transmissions = 0;
fp->pucch_config_common.deltaPUCCH_Shift = 1;
//fp->pucch_config_common.deltaPUCCH_Shift = 1;
} */
}
/// eNB kept in function name for nffapi calls, TO FIX
void init_eNB_afterRU(void) {
......@@ -883,7 +883,7 @@ void init_eNB_afterRU(void) {
"inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,gNB->gNB_config.rf_config.tx_antenna_ports.value);
LOG_I(PHY,"inst %d, CC_id %d : nb_antennas_rx %d\n",inst,CC_id,gNB->gNB_config.rf_config.tx_antenna_ports.value);
/// Transport init necessary for NR synchro
//init_transport(gNB);
init_nr_transport(gNB);
//init_precoding_weights(RC.gNB[inst][CC_id]);
}
init_gNB_proc(inst);
......
......@@ -219,7 +219,7 @@ PHY_VARS_NR_UE* init_nr_ue_vars(NR_DL_FRAME_PARMS *frame_parms,
// initialize all signal buffers
init_nr_ue_signal(ue,1,abstraction_flag);
// intialize transport
//init_nr_ue_transport(ue,abstraction_flag);
init_nr_ue_transport(ue,abstraction_flag);
return(ue);
}
......
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