Commit 268d1c8d authored by Thomas Schlichter's avatar Thomas Schlichter

Fix order of DLSCH deinterleaving and rate matching

On the gNB side tha data are first rate-matched and then interleaved.
So on the UE side, the received LLRs have to be deinterleaved first before rate-matching.

This significantly improved the performance, especially for MCS values > 3.
parent df0b9553
...@@ -467,33 +467,26 @@ void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f); ...@@ -467,33 +467,26 @@ void nr_interleaving_ldpc(uint32_t E, uint8_t Qm, uint8_t *e,uint8_t *f);
void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f); void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f);
uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, int nr_rate_matching_ldpc(uint8_t Ilbrm,
uint32_t Tbslbrm, uint32_t Tbslbrm,
uint8_t BG, uint8_t BG,
uint16_t Z, uint16_t Z,
uint32_t G,
uint8_t *w, uint8_t *w,
uint8_t *e, uint8_t *e,
uint8_t C, uint8_t C,
uint8_t rvidx, uint8_t rvidx,
uint8_t Qm, uint32_t E);
uint8_t Nl,
uint8_t r);
int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, int nr_rate_matching_ldpc_rx(uint8_t Ilbrm,
uint32_t Tbslbrm, uint32_t Tbslbrm,
uint8_t BG, uint8_t BG,
uint16_t Z, uint16_t Z,
uint32_t G,
int16_t *w, int16_t *w,
int16_t *soft_input, int16_t *soft_input,
uint8_t C, uint8_t C,
uint8_t rvidx, uint8_t rvidx,
uint8_t clear, uint8_t clear,
uint8_t Qm, uint32_t E);
uint8_t Nl,
uint8_t r,
uint32_t *E_out);
decoder_if_t phy_threegpplte_turbo_decoder; decoder_if_t phy_threegpplte_turbo_decoder;
decoder_if_t phy_threegpplte_turbo_decoder8; decoder_if_t phy_threegpplte_turbo_decoder8;
......
...@@ -63,25 +63,22 @@ void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f) ...@@ -63,25 +63,22 @@ void nr_deinterleaving_ldpc(uint32_t E, uint8_t Qm, int16_t *e,int16_t *f)
} }
uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, int nr_rate_matching_ldpc(uint8_t Ilbrm,
uint32_t Tbslbrm, uint32_t Tbslbrm,
uint8_t BG, uint8_t BG,
uint16_t Z, uint16_t Z,
uint32_t G,
uint8_t *w, uint8_t *w,
uint8_t *e, uint8_t *e,
uint8_t C, uint8_t C,
uint8_t rvidx, uint8_t rvidx,
uint8_t Qm, uint32_t E)
uint8_t Nl,
uint8_t r)
{ {
uint8_t Cprime; uint32_t Ncb,ind,k,Nref,N;
uint32_t Ncb,E,ind,k,Nref,N;
//uint8_t *e2;
AssertFatal(Nl>0,"Nl is 0\n"); if (C==0) {
AssertFatal(Qm>0,"Qm is 0\n"); printf("nr_rate_matching: invalid parameters (C %d\n",C);
return -1;
}
//Bit selection //Bit selection
N = (BG==1)?(66*Z):(50*Z); N = (BG==1)?(66*Z):(50*Z);
...@@ -93,25 +90,12 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, ...@@ -93,25 +90,12 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm,
Ncb = min(N, Nref); Ncb = min(N, Nref);
} }
#ifdef RM_DEBUG
printf("nr_rate_matching: Ncb %d, rvidx %d, G %d, Qm %d, Nl%d, r %d\n",Ncb,rvidx, G, Qm,Nl,r);
#endif
Cprime = C; //assume CBGTI not present
if (r <= Cprime - ((G/(Nl*Qm))%Cprime) - 1)
E = Nl*Qm*(G/(Nl*Qm*Cprime));
else
E = Nl*Qm*((G/(Nl*Qm*Cprime))+1);
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 Cprime %d modcprime %d\n",E,ind, Cprime,((G/(Nl*Qm))%Cprime)); printf("nr_rate_matching_ldpc: E %d, k0 %d, Ncb %d, rvidx %d\n", E, ind, Ncb, rvidx);
#endif #endif
//e2 = e;
k=0; k=0;
for (; (ind<Ncb)&&(k<E); ind++) { for (; (ind<Ncb)&&(k<E); ind++) {
...@@ -120,7 +104,6 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, ...@@ -120,7 +104,6 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm,
printf("RM_TX k%d Ind: %d (%d)\n",k,ind,w[ind]); printf("RM_TX k%d Ind: %d (%d)\n",k,ind,w[ind]);
#endif #endif
//if (w[ind] != NR_NULL) e2[k++]=w[ind];
if (w[ind] != NR_NULL) e[k++]=w[ind]; if (w[ind] != NR_NULL) e[k++]=w[ind];
} }
...@@ -131,47 +114,36 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm, ...@@ -131,47 +114,36 @@ uint32_t nr_rate_matching_ldpc(uint8_t Ilbrm,
printf("RM_TX k%d Ind: %d (%d)\n",k,ind,w[ind]); printf("RM_TX k%d Ind: %d (%d)\n",k,ind,w[ind]);
#endif #endif
//if (w[ind] != NR_NULL) e2[k++]=w[ind];
if (w[ind] != NR_NULL) e[k++]=w[ind]; if (w[ind] != NR_NULL) e[k++]=w[ind];
} }
} }
return(E); return 0;
} }
int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, int nr_rate_matching_ldpc_rx(uint8_t Ilbrm,
uint32_t Tbslbrm, uint32_t Tbslbrm,
uint8_t BG, uint8_t BG,
uint16_t Z, uint16_t Z,
uint32_t G,
int16_t *w, int16_t *w,
int16_t *soft_input, int16_t *soft_input,
uint8_t C, uint8_t C,
uint8_t rvidx, uint8_t rvidx,
uint8_t clear, uint8_t clear,
uint8_t Qm, uint32_t E)
uint8_t Nl,
uint8_t r,
uint32_t *E_out)
{ {
uint8_t Cprime; uint32_t Ncb,ind,k,Nref,N;
uint32_t Ncb,E,ind,k,Nref,N;
int16_t *soft_input2;
#ifdef RM_DEBUG #ifdef RM_DEBUG
int nulled=0; int nulled=0;
#endif #endif
if (C==0 || Qm==0 || Nl==0) { if (C==0) {
printf("nr_rate_matching: invalid parameters (C %d, Qm %d, Nl %d\n",C,Qm,Nl); printf("nr_rate_matching: invalid parameters (C %d\n",C);
return(-1); return -1;
} }
AssertFatal(Nl>0,"Nl is 0\n");
AssertFatal(Qm>0,"Qm is 0\n");
//Bit selection //Bit selection
N = (BG==1)?(66*Z):(50*Z); N = (BG==1)?(66*Z):(50*Z);
...@@ -182,28 +154,20 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, ...@@ -182,28 +154,20 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm,
Ncb = min(N, Nref); Ncb = min(N, Nref);
} }
Cprime = C; //assume CBGTI not present
if (r <= Cprime - ((G/(Nl*Qm))%Cprime) - 1)
E = Nl*Qm*(G/(Nl*Qm*Cprime));
else
E = Nl*Qm*((G/(Nl*Qm*Cprime))+1);
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_ldpc_rx: Clear %d, E %d, Ncb %d,rvidx %d, G %d, Qm %d, Nl%d, r %d\n",clear,E,Ncb,rvidx, G, Qm,Nl,r); printf("nr_rate_matching_ldpc_rx: Clear %d, E %d, k0 %d, Ncb %d, rvidx %d\n", clear, E, ind, Ncb, rvidx);
#endif #endif
if (clear==1) if (clear==1)
memset(w,0,Ncb*sizeof(int16_t)); memset(w,0,Ncb*sizeof(int16_t));
soft_input2 = soft_input;
k=0; k=0;
for (; (ind<Ncb)&&(k<E); ind++) { for (; (ind<Ncb)&&(k<E); ind++) {
if (soft_input2[ind] != NR_NULL) { if (soft_input[ind] != NR_NULL) {
w[ind] += soft_input2[k++]; w[ind] += soft_input[k++];
#ifdef RM_DEBUG #ifdef RM_DEBUG
printf("RM_RX k%d Ind: %d (%d)\n",k-1,ind,w[ind]); printf("RM_RX k%d Ind: %d (%d)\n",k-1,ind,w[ind]);
#endif #endif
...@@ -220,10 +184,10 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, ...@@ -220,10 +184,10 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm,
while(k<E) { while(k<E) {
for (ind=0; (ind<Ncb)&&(k<E); ind++) { for (ind=0; (ind<Ncb)&&(k<E); ind++) {
if (soft_input2[ind] != NR_NULL) { if (soft_input[ind] != NR_NULL) {
w[ind] += soft_input2[k++]; w[ind] += soft_input[k++];
#ifdef RM_DEBUG #ifdef RM_DEBUG
printf("RM_RX k%d Ind: %d (%d)(soft in %d)\n",k-1,ind,w[ind],soft_input2[k-1]); printf("RM_RX k%d Ind: %d (%d)(soft in %d)\n",k-1,ind,w[ind],soft_input[k-1]);
#endif #endif
} }
...@@ -237,7 +201,5 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm, ...@@ -237,7 +201,5 @@ int nr_rate_matching_ldpc_rx(uint8_t Ilbrm,
} }
} }
*E_out = E; return 0;
return(0);
} }
...@@ -90,6 +90,8 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t dlsch, ...@@ -90,6 +90,8 @@ uint8_t nr_generate_pdsch(NR_gNB_DLSCH_t dlsch,
@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, uint8_t Nl); 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 nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r);
void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); void free_gNB_dlsch(NR_gNB_DLSCH_t *dlsch);
void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch); void clean_gNB_dlsch(NR_gNB_DLSCH_t *dlsch);
......
...@@ -406,18 +406,17 @@ int nr_dlsch_encoding(unsigned char *a, ...@@ -406,18 +406,17 @@ int nr_dlsch_encoding(unsigned char *a,
printf("rvidx in encoding = %d\n", rel15.redundancy_version); printf("rvidx in encoding = %d\n", rel15.redundancy_version);
#endif #endif
E = nr_rate_matching_ldpc(Ilbrm, E = nr_get_E(G, dlsch->harq_processes[harq_pid]->C, mod_order, rel15.nb_layers, r);
nr_rate_matching_ldpc(Ilbrm,
Tbslbrm, Tbslbrm,
BG, BG,
*pz, *pz,
G,
dlsch->harq_processes[harq_pid]->d[r], dlsch->harq_processes[harq_pid]->d[r],
dlsch->harq_processes[harq_pid]->e+r_offset, dlsch->harq_processes[harq_pid]->e+r_offset,
dlsch->harq_processes[harq_pid]->C, dlsch->harq_processes[harq_pid]->C,
rel15.redundancy_version, rel15.redundancy_version,
mod_order, E);
rel15.nb_layers,
r);
#ifdef DEBUG_DLSCH_CODING #ifdef DEBUG_DLSCH_CODING
for (int i =0; i<16; i++) for (int i =0; i<16; i++)
......
...@@ -176,3 +176,18 @@ uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16 ...@@ -176,3 +176,18 @@ uint32_t nr_get_G(uint16_t nb_rb, uint16_t nb_symb_sch,uint8_t nb_re_dmrs,uint16
G = ((NR_NB_SC_PER_RB*nb_symb_sch)-(nb_re_dmrs*length_dmrs))*nb_rb*Qm*Nl; G = ((NR_NB_SC_PER_RB*nb_symb_sch)-(nb_re_dmrs*length_dmrs))*nb_rb*Qm*Nl;
return(G); return(G);
} }
uint32_t nr_get_E(uint32_t G, uint8_t C, uint8_t Qm, uint8_t Nl, uint8_t r) {
uint32_t E;
uint8_t Cprime = C; //assume CBGTI not present
AssertFatal(Nl>0,"Nl is 0\n");
AssertFatal(Qm>0,"Qm is 0\n");
if (r <= Cprime - ((G/(Nl*Qm))%Cprime) - 1)
E = Nl*Qm*(G/(Nl*Qm*Cprime));
else
E = Nl*Qm*((G/(Nl*Qm*Cprime))+1);
return E;
}
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