Fixed compilation issue in cqi.c

master
ismagom 10 years ago
parent 2c93d2a1c9
commit aee245b774

@ -64,7 +64,7 @@ LIBLTE_API void cqi_hl_subband_pack(cqi_hl_subband_t *msg,
uint8_t *buff, uint8_t *buff,
uint32_t buff_len); uint32_t buff_len);
LIBLTE_API void cqi_ue_subband_pack(cqi_hl_subband_t *msg, LIBLTE_API void cqi_ue_subband_pack(cqi_ue_subband_t *msg,
uint32_t L, uint32_t L,
uint8_t *buff, uint8_t *buff,
uint32_t buff_len); uint32_t buff_len);

@ -58,10 +58,11 @@ typedef struct LIBLTE_API {
cf_t *pusch_symbols[MAX_PORTS]; cf_t *pusch_symbols[MAX_PORTS];
cf_t *pusch_x[MAX_PORTS]; cf_t *pusch_x[MAX_PORTS];
cf_t *pusch_d; cf_t *pusch_d;
void *pusch_e;
uint8_t *pusch_q_ri; void *pusch_q;
uint8_t *pusch_q_ack; uint8_t *pusch_g_ri;
uint8_t *pusch_g_ack;
void *pusch_g;
/* tx & rx objects */ /* tx & rx objects */
modem_table_t mod[4]; modem_table_t mod[4];

@ -96,18 +96,20 @@ LIBLTE_API int dlsch_decode(sch_t *q,
LIBLTE_API int ulsch_encode(sch_t *q, LIBLTE_API int ulsch_encode(sch_t *q,
uint8_t *data, uint8_t *data,
uint8_t *q_bits, uint8_t *g_bits,
harq_t *harq_process, harq_t *harq_process,
uint32_t rv_idx); uint32_t rv_idx,
uint8_t *q_bits);
LIBLTE_API int ulsch_uci_encode(sch_t *q, LIBLTE_API int ulsch_uci_encode(sch_t *q,
uint8_t *data, uint8_t *data,
uci_data_t uci_data, uci_data_t uci_data,
uint8_t *q_bits, uint8_t *g_bits,
uint8_t *q_bits_ack, uint8_t *g_bits_ack,
uint8_t *q_bits_ri, uint8_t *g_bits_ri,
harq_t *harq_process, harq_t *harq_process,
uint32_t rv_idx); uint32_t rv_idx,
uint8_t *q_bits);
LIBLTE_API int ulsch_decode(sch_t *q, LIBLTE_API int ulsch_decode(sch_t *q,
float *e_bits, float *e_bits,

@ -120,19 +120,25 @@ int pusch_init(pusch_t *q, lte_cell_t cell) {
q->rnti_is_set = false; q->rnti_is_set = false;
// Allocate floats for reception (LLRs) // Allocate floats for reception (LLRs). Buffer casted to uint8_t for transmission
q->pusch_e = malloc(sizeof(float) * q->max_symbols * lte_mod_bits_x_symbol(LTE_QAM64)); q->pusch_q = malloc(sizeof(float) * q->max_symbols * lte_mod_bits_x_symbol(LTE_QAM64));
if (!q->pusch_e) { if (!q->pusch_q) {
goto clean;
}
// Allocate floats for reception (LLRs). Buffer casted to uint8_t for transmission
q->pusch_g = malloc(sizeof(float) * q->max_symbols * lte_mod_bits_x_symbol(LTE_QAM64));
if (!q->pusch_g) {
goto clean; goto clean;
} }
// Allocate buffers for q bits for coded RI and ACK bits // Allocate buffers for q bits for coded RI and ACK bits
q->pusch_q_ack = malloc(sizeof(uint8_t) * 4 * q->cell.nof_prb * lte_mod_bits_x_symbol(LTE_QAM64)); q->pusch_g_ack = malloc(sizeof(uint8_t) * 4 * q->cell.nof_prb * lte_mod_bits_x_symbol(LTE_QAM64));
if (!q->pusch_q_ack) { if (!q->pusch_g_ack) {
goto clean; goto clean;
} }
q->pusch_q_ri = malloc(sizeof(uint8_t) * 4 * q->cell.nof_prb * lte_mod_bits_x_symbol(LTE_QAM64)); q->pusch_g_ri = malloc(sizeof(uint8_t) * 4 * q->cell.nof_prb * lte_mod_bits_x_symbol(LTE_QAM64));
if (!q->pusch_q_ri) { if (!q->pusch_g_ri) {
goto clean; goto clean;
} }
@ -168,17 +174,17 @@ int pusch_init(pusch_t *q, lte_cell_t cell) {
void pusch_free(pusch_t *q) { void pusch_free(pusch_t *q) {
int i; int i;
if (q->pusch_e) { if (q->pusch_q) {
free(q->pusch_e); free(q->pusch_q);
} }
if (q->pusch_d) { if (q->pusch_d) {
free(q->pusch_d); free(q->pusch_d);
} }
if (q->pusch_q_ack) { if (q->pusch_g_ack) {
free(q->pusch_q_ack); free(q->pusch_g_ack);
} }
if (q->pusch_q_ri) { if (q->pusch_g_ri) {
free(q->pusch_q_ri); free(q->pusch_g_ri);
} }
for (i = 0; i < q->cell.nof_ports; i++) { for (i = 0; i < q->cell.nof_ports; i++) {
if (q->ce[i]) { if (q->ce[i]) {
@ -276,12 +282,12 @@ int pusch_decode(pusch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS], float noise_
*/ */
demod_soft_sigma_set(&q->demod, sqrt(0.5)); demod_soft_sigma_set(&q->demod, sqrt(0.5));
demod_soft_table_set(&q->demod, &q->mod[harq_process->mcs.mod]); demod_soft_table_set(&q->demod, &q->mod[harq_process->mcs.mod]);
demod_soft_demodulate(&q->demod, q->pusch_d, q->pusch_e, nof_symbols); demod_soft_demodulate(&q->demod, q->pusch_d, q->pusch_q, nof_symbols);
/* descramble */ /* descramble */
scrambling_f_offset(&q->seq_pusch[subframe], q->pusch_e, 0, nof_bits_e); scrambling_f_offset(&q->seq_pusch[subframe], q->pusch_q, 0, nof_bits_e);
return ulsch_decode(&q->dl_sch, q->pusch_e, data, nof_bits, nof_bits_e, harq_process, rv_idx); return ulsch_decode(&q->dl_sch, q->pusch_q, data, nof_bits, nof_bits_e, harq_process, rv_idx);
} else { } else {
fprintf(stderr, "Must call pusch_set_rnti() before calling pusch_decode()\n"); fprintf(stderr, "Must call pusch_set_rnti() before calling pusch_decode()\n");
return LIBLTE_ERROR; return LIBLTE_ERROR;
@ -292,7 +298,7 @@ int pusch_decode(pusch_t *q, cf_t *sf_symbols, cf_t *ce[MAX_PORTS], float noise_
} }
} }
int pusch_encode(pusch_t *q, uint8_t *data, cf_t *sf_symbols[MAX_PORTS], uint32_t subframe, int pusch_qncode(pusch_t *q, uint8_t *data, cf_t *sf_symbols[MAX_PORTS], uint32_t subframe,
harq_t *harq_process, uint32_t rv_idx) harq_t *harq_process, uint32_t rv_idx)
{ {
uci_data_t uci_data; uci_data_t uci_data;
@ -354,16 +360,16 @@ int pusch_uci_encode(pusch_t *q, uint8_t *data, uci_data_t uci_data,
} }
memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports)); memset(&x[q->cell.nof_ports], 0, sizeof(cf_t*) * (MAX_LAYERS - q->cell.nof_ports));
if (ulsch_uci_encode(&q->dl_sch, data, uci_data, q->pusch_e, if (ulsch_uci_encode(&q->dl_sch, data, uci_data, q->pusch_g,
q->pusch_q_ack, q->pusch_q_ri, harq_process, rv_idx)) q->pusch_g_ack, q->pusch_g_ri, harq_process, rv_idx, q->pusch_q))
{ {
fprintf(stderr, "Error encoding TB\n"); fprintf(stderr, "Error encoding TB\n");
return LIBLTE_ERROR; return LIBLTE_ERROR;
} }
scrambling_b_offset_pusch(&q->seq_pusch[subframe], (uint8_t*) q->pusch_e, 0, nof_bits_e); scrambling_b_offset_pusch(&q->seq_pusch[subframe], (uint8_t*) q->pusch_q, 0, nof_bits_e);
mod_modulate(&q->mod[harq_process->mcs.mod], (uint8_t*) q->pusch_e, q->pusch_d, nof_bits_e); mod_modulate(&q->mod[harq_process->mcs.mod], (uint8_t*) q->pusch_q, q->pusch_d, nof_bits_e);
/* mapping to resource elements */ /* mapping to resource elements */

@ -410,7 +410,7 @@ uint8_t ulsch_y_mat[10000];
void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q, void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
uint8_t q_bits_ack[6], uint32_t Q_prime_ack, uint8_t q_bits_ack[6], uint32_t Q_prime_ack,
uint8_t q_bits_ri[6], uint32_t Q_prime_ri, uint8_t q_bits_ri[6], uint32_t Q_prime_ri,
uint32_t Q_m) uint32_t Q_m, uint8_t *g_bits)
{ {
uint32_t C_mux; uint32_t C_mux;
uint32_t H_prime; uint32_t H_prime;
@ -498,26 +498,25 @@ void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
for(i=0; i<C_mux; i++) { for(i=0; i<C_mux; i++) {
for(j=0; j<R_prime_mux; j++) { for(j=0; j<R_prime_mux; j++) {
for(k=0; k<Q_m; k++) { for(k=0; k<Q_m; k++) {
q_bits[idx++] = ulsch_y_mat[j*C_mux*Q_m + i*Q_m + k]; g_bits[idx++] = ulsch_y_mat[j*C_mux*Q_m + i*Q_m + k];
} }
} }
} }
} }
int ulsch_encode(sch_t *q, uint8_t *data, uint8_t *g_bits,
int ulsch_encode(sch_t *q, uint8_t *data, uint8_t *q_bits, harq_t *harq_process, uint32_t rv_idx, uint8_t *q_bits)
harq_t *harq_process, uint32_t rv_idx)
{ {
uci_data_t uci_data; uci_data_t uci_data;
bzero(&uci_data, sizeof(uci_data_t)); bzero(&uci_data, sizeof(uci_data_t));
return ulsch_uci_encode(q, data, uci_data, q_bits, NULL, NULL, harq_process, rv_idx); return ulsch_uci_encode(q, data, uci_data, g_bits, NULL, NULL, harq_process, rv_idx, q_bits);
} }
int ulsch_uci_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *q_bits, int ulsch_uci_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *g_bits,
uint8_t *q_bits_ack, uint8_t *q_bits_ri, uint8_t *g_bits_ack, uint8_t *g_bits_ri,
harq_t *harq_process, uint32_t rv_idx) harq_t *harq_process, uint32_t rv_idx, uint8_t *q_bits)
{ {
int ret; int ret;
@ -536,7 +535,7 @@ int ulsch_uci_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *q_bi
if (harq_process->mcs.tbs == 0) { if (harq_process->mcs.tbs == 0) {
beta /= uci_data.beta_cqi; beta /= uci_data.beta_cqi;
} }
ret = uci_encode_ri_ack(uci_data.uci_ack, uci_data.uci_cqi_len, beta, harq_process, q_bits_ack); ret = uci_encode_ri_ack(uci_data.uci_ack, uci_data.uci_cqi_len, beta, harq_process, g_bits_ack);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
@ -549,7 +548,7 @@ int ulsch_uci_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *q_bi
if (harq_process->mcs.tbs == 0) { if (harq_process->mcs.tbs == 0) {
beta /= uci_data.beta_cqi; beta /= uci_data.beta_cqi;
} }
ret = uci_encode_ri_ack(uci_data.uci_ri, uci_data.uci_cqi_len, beta, harq_process, q_bits_ri); ret = uci_encode_ri_ack(uci_data.uci_ri, uci_data.uci_cqi_len, beta, harq_process, g_bits_ri);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
@ -559,7 +558,7 @@ int ulsch_uci_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *q_bi
// Encode CQI // Encode CQI
if (uci_data.uci_cqi_len > 0) { if (uci_data.uci_cqi_len > 0) {
ret = uci_encode_cqi(&q->uci_cqi, uci_data.uci_cqi, uci_data.uci_cqi_len, uci_data.beta_cqi, ret = uci_encode_cqi(&q->uci_cqi, uci_data.uci_cqi, uci_data.uci_cqi_len, uci_data.beta_cqi,
Q_prime_ri, harq_process, q_bits); Q_prime_ri, harq_process, g_bits);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
@ -572,7 +571,7 @@ int ulsch_uci_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *q_bi
// Encode UL-SCH // Encode UL-SCH
if (harq_process->mcs.tbs > 0) { if (harq_process->mcs.tbs > 0) {
uint32_t G = nb_q/Q_m - Q_prime_ri - Q_prime_cqi; uint32_t G = nb_q/Q_m - Q_prime_ri - Q_prime_cqi;
ret = encode_tb(q, data, &q_bits[e_offset], harq_process->mcs.tbs, ret = encode_tb(q, data, &g_bits[e_offset], harq_process->mcs.tbs,
G*Q_m, harq_process, rv_idx); G*Q_m, harq_process, rv_idx);
if (ret) { if (ret) {
return ret; return ret;
@ -580,10 +579,10 @@ int ulsch_uci_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *q_bi
} }
// Multiplexing and Interleaving // Multiplexing and Interleaving
ulsch_interleave(q_bits, nb_q/Q_m-Q_prime_ri, ulsch_interleave(g_bits, nb_q/Q_m-Q_prime_ri,
q_bits_ack, Q_prime_ack, g_bits_ack, Q_prime_ack,
q_bits_ri, Q_prime_ri, g_bits_ri, Q_prime_ri,
Q_m); Q_m, q_bits);

@ -199,21 +199,22 @@ int main(int argc, char **argv) {
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 = tmp;
uci_data.uci_cqi_len = 10; uci_data.uci_cqi_len = 0;
uci_data.uci_ri_len = 1; uci_data.uci_ri_len = 1;
uci_data.uci_ack_len = 0; uci_data.uci_ack_len = 0;
uci_data.uci_ri = 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;
uint32_t nof_bits_e = nof_symbols * lte_mod_bits_x_symbol(harq_process.mcs.mod); uint32_t nof_bits_e = nof_symbols * lte_mod_bits_x_symbol(harq_process.mcs.mod);
if (ulsch_uci_encode(&pusch.dl_sch, data, uci_data, pusch.pusch_e, if (ulsch_uci_encode(&pusch.dl_sch, data, uci_data, pusch.pusch_g,
pusch.pusch_q_ack, pusch.pusch_q_ri, &harq_process, rv)) pusch.pusch_g_ack, pusch.pusch_g_ri, &harq_process, rv, pusch.pusch_q))
{ {
fprintf(stderr, "Error encoding TB\n"); fprintf(stderr, "Error encoding TB\n");
exit(-1); exit(-1);
} }
vec_fprint_b(stdout, pusch.pusch_e, nof_bits_e); vec_fprint_b(stdout, pusch.pusch_q, nof_bits_e);
/* combine outputs */ /* combine outputs */
for (i=0;i<cell.nof_ports;i++) { for (i=0;i<cell.nof_ports;i++) {

@ -160,17 +160,21 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
if (!q_bits) { if (!q_bits) {
return; return;
} }
uint8_t *q_bits_ack = vec_malloc(nof_q_bits * sizeof(uint8_t)); uint8_t *g_bits = vec_malloc(nof_q_bits * sizeof(uint8_t));
if (!q_bits_ack) { if (!g_bits) {
return; return;
} }
uint8_t *q_bits_ri = vec_malloc(nof_q_bits * sizeof(uint8_t)); uint8_t *g_bits_ack = vec_malloc(nof_q_bits * sizeof(uint8_t));
if (!q_bits_ri) { if (!g_bits_ack) {
return;
}
uint8_t *g_bits_ri = vec_malloc(nof_q_bits * sizeof(uint8_t));
if (!g_bits_ri) {
return; return;
} }
if (ulsch_uci_encode(&ulsch, trblkin, uci_data, q_bits, if (ulsch_uci_encode(&ulsch, trblkin, uci_data, g_bits,
q_bits_ack, q_bits_ri, &harq_process, rv)) g_bits_ack, g_bits_ri, &harq_process, rv, q_bits))
{ {
mexErrMsgTxt("Error encoding TB\n"); mexErrMsgTxt("Error encoding TB\n");
return; return;
@ -183,9 +187,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
sch_free(&ulsch); sch_free(&ulsch);
free(trblkin); free(trblkin);
free(q_bits); free(g_bits);
free(q_bits_ack); free(g_bits_ack);
free(q_bits_ri); free(g_bits_ri);
if (uci_data.uci_cqi_len > 0) { if (uci_data.uci_cqi_len > 0) {
free(uci_data.uci_cqi); free(uci_data.uci_cqi);

@ -3,21 +3,21 @@ puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',0,'Modulation','QPSK',
addpath('../../debug/lte/phy/lib/phch/test') addpath('../../debug/lte/phy/lib/phch/test')
TBs=99; TBs=100;
error=zeros(size(TBs)); error=zeros(size(TBs));
for i=1:length(error) for i=1:length(error)
trblkin=randi(2,TBs(i),1)-1; %trblkin=randi(2,TBs(i),1)-1;
%trblkin=ones(TBs(i),1); trblkin=ones(TBs(i),1);
%trblkin=[]; %trblkin=[];
puschConfig.BetaCQI = 2.0; puschConfig.BetaCQI = 2.0;
puschConfig.BetaRI = 2.0; puschConfig.BetaRI = 2.0;
puschConfig.BetaACK = 2.0; puschConfig.BetaACK = 2.0;
[mat, info]=lteULSCH(ueConfig,puschConfig,trblkin,[],[],[],[]); [mat, info]=lteULSCH(ueConfig,puschConfig,trblkin,[],[1],[],[]);
mat(mat==-2)=2; mat(mat==-2)=2;
mat(mat==-1)=3; mat(mat==-1)=3;
[lib]=liblte_ulsch_encode(ueConfig,puschConfig,trblkin,[],[],[]); [lib]=liblte_ulsch_encode(ueConfig,puschConfig,trblkin,[],[1],[]);
error(i)=sum(abs(double(mat)-double(lib))); error(i)=sum(abs(double(mat)-double(lib)));
if (length(TBs) == 1) if (length(TBs) == 1)
disp(error(i)) disp(error(i))

Loading…
Cancel
Save