Allowed UL-SCH test and mex to run with RV idx > 0 and fixed memory leak in MEX

master
ismagom 10 years ago
parent a3ae7a3264
commit 908e4f0373

@ -131,6 +131,7 @@ int harq_init(harq_t *q, lte_cell_t cell) {
perror("malloc"); perror("malloc");
return LIBLTE_ERROR; return LIBLTE_ERROR;
} }
bzero(q->pdsch_w_buff_c[i], sizeof(uint8_t) * q->w_buff_size);
} }
ret = LIBLTE_SUCCESS; ret = LIBLTE_SUCCESS;
} }

@ -203,7 +203,7 @@ static int uci_ulsch_interleave_ack(uint8_t ack_coded_bits[6], uint32_t ack_q_bi
const uint32_t ack_column_set_norm[4] = {2, 3, 8, 9}; const uint32_t ack_column_set_norm[4] = {2, 3, 8, 9};
const uint32_t ack_column_set_ext[4] = {1, 2, 6, 7}; const uint32_t ack_column_set_ext[4] = {1, 2, 6, 7};
if (H_prime_total/N_pusch_symbs > 1+ack_q_bit_idx/4) { if (H_prime_total/N_pusch_symbs >= 1+ack_q_bit_idx/4) {
uint32_t row = H_prime_total/N_pusch_symbs-1-ack_q_bit_idx/4; uint32_t row = H_prime_total/N_pusch_symbs-1-ack_q_bit_idx/4;
uint32_t colidx = (3*ack_q_bit_idx)%4; uint32_t colidx = (3*ack_q_bit_idx)%4;
uint32_t col = CP_ISNORM(cp)?ack_column_set_norm[colidx]:ack_column_set_ext[colidx]; uint32_t col = CP_ISNORM(cp)?ack_column_set_norm[colidx]:ack_column_set_ext[colidx];
@ -227,7 +227,7 @@ static int uci_ulsch_interleave_ri(uint8_t ri_coded_bits[6], uint32_t ri_q_bit_i
static uint32_t ri_column_set_norm[4] = {1, 4, 7, 10}; static uint32_t ri_column_set_norm[4] = {1, 4, 7, 10};
static uint32_t ri_column_set_ext[4] = {0, 3, 5, 8}; static uint32_t ri_column_set_ext[4] = {0, 3, 5, 8};
if (H_prime_total/N_pusch_symbs > 1+ri_q_bit_idx/4) { if (H_prime_total/N_pusch_symbs >= 1+ri_q_bit_idx/4) {
uint32_t row = H_prime_total/N_pusch_symbs-1-ri_q_bit_idx/4; uint32_t row = H_prime_total/N_pusch_symbs-1-ri_q_bit_idx/4;
uint32_t colidx = (3*ri_q_bit_idx)%4; uint32_t colidx = (3*ri_q_bit_idx)%4;
uint32_t col = CP_ISNORM(cp)?ri_column_set_norm[colidx]:ri_column_set_ext[colidx]; uint32_t col = CP_ISNORM(cp)?ri_column_set_norm[colidx]:ri_column_set_ext[colidx];

@ -125,7 +125,6 @@ int main(int argc, char **argv) {
ra_mcs_t mcs; ra_mcs_t mcs;
ra_prb_t prb_alloc; ra_prb_t prb_alloc;
harq_t harq_process; harq_t harq_process;
uint32_t rv = 0;
parse_args(argc,argv); parse_args(argc,argv);
@ -186,8 +185,7 @@ int main(int argc, char **argv) {
printf("INPUT: "); printf("INPUT: ");
vec_fprint_b(stdout, data, mcs.tbs); vec_fprint_b(stdout, data, mcs.tbs);
for (rv=0;rv<=rv_idx;rv++) { printf("Encoding rv_idx=%d\n",rv_idx);
printf("Encoding rv_idx=%d\n",rv);
uint8_t tmp[20]; uint8_t tmp[20];
for (i=0;i<20;i++) { for (i=0;i<20;i++) {
@ -198,11 +196,13 @@ int main(int argc, char **argv) {
uci_data.beta_cqi = 2.0; uci_data.beta_cqi = 2.0;
uci_data.beta_ri = 2.0; uci_data.beta_ri = 2.0;
uci_data.beta_ack = 2.0; uci_data.beta_ack = 2.0;
uci_data.uci_cqi = tmp;
uci_data.uci_cqi_len = 0; uci_data.uci_cqi_len = 0;
uci_data.uci_ri_len = 1; uci_data.uci_ri_len = 0;
uci_data.uci_ack_len = 0;
uci_data.uci_cqi = tmp;
uci_data.uci_ri = 1; uci_data.uci_ri = 1;
uci_data.uci_ack_len = 1;
uci_data.uci_ack = 1; uci_data.uci_ack = 1;
uint32_t nof_symbols = 12*harq_process.prb_alloc.slot[0].nof_prb*RE_X_RB; uint32_t nof_symbols = 12*harq_process.prb_alloc.slot[0].nof_prb*RE_X_RB;
@ -211,12 +211,20 @@ int main(int argc, char **argv) {
bzero(pusch.pusch_q, nof_bits_e*sizeof(uint8_t)); bzero(pusch.pusch_q, nof_bits_e*sizeof(uint8_t));
if (ulsch_uci_encode(&pusch.dl_sch, data, uci_data, pusch.pusch_g, &harq_process, rv, pusch.pusch_q)) if (ulsch_uci_encode(&pusch.dl_sch, data, uci_data, pusch.pusch_g, &harq_process, 0, pusch.pusch_q))
{ {
fprintf(stderr, "Error encoding TB\n"); fprintf(stderr, "Error encoding TB\n");
exit(-1); exit(-1);
} }
if (rv_idx > 0) {
if (ulsch_uci_encode(&pusch.dl_sch, data, uci_data, pusch.pusch_g, &harq_process, rv_idx, pusch.pusch_q))
{
fprintf(stderr, "Error encoding TB\n");
exit(-1);
}
}
vec_fprint_b(stdout, pusch.pusch_q, nof_bits_e); vec_fprint_b(stdout, pusch.pusch_q, nof_bits_e);
/* combine outputs */ /* combine outputs */
@ -242,7 +250,6 @@ int main(int argc, char **argv) {
printf("DECODED OK in %d:%d (%.2f Mbps)\n", (int) t[0].tv_sec, (int) t[0].tv_usec, (float) mcs.tbs/t[0].tv_usec); printf("DECODED OK in %d:%d (%.2f Mbps)\n", (int) t[0].tv_sec, (int) t[0].tv_usec, (float) mcs.tbs/t[0].tv_usec);
} }
}
ret = 0; ret = 0;
quit: quit:
pusch_free(&pusch); pusch_free(&pusch);

@ -144,7 +144,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
free(prbset); free(prbset);
printf("Q_m: %d, NPRB: %d, RV: %d\n", lte_mod_bits_x_symbol(mcs.mod), prb_alloc.slot[0].nof_prb, rv); mexPrintf("Q_m: %d, NPRB: %d, RV: %d\n", lte_mod_bits_x_symbol(mcs.mod), prb_alloc.slot[0].nof_prb, rv);
if (harq_setup(&harq_process, mcs, &prb_alloc)) { if (harq_setup(&harq_process, mcs, &prb_alloc)) {
mexErrMsgTxt("Error configuring HARQ process\n"); mexErrMsgTxt("Error configuring HARQ process\n");
@ -163,24 +163,30 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return; return;
} }
if (ulsch_uci_encode(&ulsch, trblkin, uci_data, g_bits, &harq_process, 0, q_bits))
{
mexErrMsgTxt("Error encoding TB\n");
return;
}
if (rv > 0) {
if (ulsch_uci_encode(&ulsch, trblkin, uci_data, g_bits, &harq_process, rv, q_bits)) if (ulsch_uci_encode(&ulsch, trblkin, uci_data, g_bits, &harq_process, rv, q_bits))
{ {
mexErrMsgTxt("Error encoding TB\n"); mexErrMsgTxt("Error encoding TB\n");
return; return;
} }
}
if (nlhs >= 1) { if (nlhs >= 1) {
mexutils_write_uint8(q_bits, &plhs[0], nof_q_bits, 1); mexutils_write_uint8(q_bits, &plhs[0], nof_q_bits, 1);
} }
sch_free(&ulsch); sch_free(&ulsch);
harq_free(&harq_process);
free(trblkin); free(trblkin);
free(g_bits); free(g_bits);
free(q_bits);
if (uci_data.uci_cqi_len > 0) {
free(uci_data.uci_cqi); free(uci_data.uci_cqi);
}
return; return;
} }

@ -1,26 +1,58 @@
clear
ueConfig=struct('NCellID',1,'CyclicPrefixUL','Normal','NTxAnts',1); ueConfig=struct('NCellID',1,'CyclicPrefixUL','Normal','NTxAnts',1);
puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',(0:1)','Modulation','16QAM','RV',0,'Shortened',0); puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',0,'Modulation','16QAM','RV',0,'Shortened',0);
addpath('../../debug/lte/phy/lib/phch/test') addpath('../../debug/lte/phy/lib/phch/test')
TBs=200; TBs=0:13:222;
error=zeros(size(TBs)); cqilen=[0, 8, 17];
for i=1:length(error) mods={'QPSK','16QAM','64QAM'};
rvs=[0, 3];
betas=0:3:11;
for i=1:length(TBs)
for m=1:length(mods)
for r=1:length(rvs)
for bcqi=1:length(betas)
for bri=1:length(betas)
for back=1:length(betas)
for c=1:length(cqilen)
trblkin=randi(2,TBs(i),1)-1; trblkin=randi(2,TBs(i),1)-1;
%trblkin=ones(TBs(i),1);
%trblkin=[];
puschConfig.BetaCQI = 2.0; puschConfig.Modulation = mods{m};
puschConfig.BetaRI = 2.0; puschConfig.RV = rvs(r);
puschConfig.BetaACK = 2.0; puschConfig.BetaCQI = 2+betas(bcqi);
puschConfig.BetaRI = 2+betas(bri);
puschConfig.BetaACK = 2+betas(back);
if (betas(bri)>0)
ri_bit=randi(2,1,1)-1;
else
ri_bit=[];
end
if (betas(back)>0)
ack_bit=randi(2,1,1)-1;
else
ack_bit=[];
end
[mat, info]=lteULSCH(ueConfig,puschConfig,trblkin,[ones(1,20)],[1],[1],[]); if (cqilen(c)>0 || TBs(i)>0)
[mat, info]=lteULSCH(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit,[]);
mat(mat==-2)=2; mat(mat==-2)=2;
mat(mat==-1)=3; mat(mat==-1)=3;
[lib]=liblte_ulsch_encode(ueConfig,puschConfig,trblkin,[ones(1,20)],[1],[1]); [lib]=liblte_ulsch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit);
error(i)=sum(abs(double(mat)-double(lib))); err=sum(abs(double(mat)-double(lib)));
if (length(TBs) == 1) if (err > 0)
disp(error(i)) disp(err)
error('Error!');
end
end
end
end
end
end
end
end end
end end
@ -29,7 +61,4 @@ if (length(TBs) == 1)
n=1:length(mat); n=1:length(mat);
%plot(abs(double(mat)-double(lib))) %plot(abs(double(mat)-double(lib)))
plot(n,lib(n),n,mat(n)) plot(n,lib(n),n,mat(n))
else
plot(error)
disp(sum(error))
end end

Loading…
Cancel
Save