PUSCH working w and w/o UCI (HARQ, RI and CQI)

This commit is contained in:
ismagom 2015-02-09 11:32:47 +01:00
parent a47461a6f5
commit 45f9917ad4
11 changed files with 435 additions and 80 deletions

View File

@ -0,0 +1,72 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef CQI_
#define CQI_
#include <stdint.h>
#include "liblte/config.h"
#include "liblte/phy/common/phy_common.h"
/**
* CQI message generation according to 36.212 Sections 5.2.2.6 and 5.2.3.3
*
*/
/* Table 5.2.2.6.2-1: Fields for channel quality information feedback for higher layer configured subband
CQI reports
(transmission mode 1, transmission mode 2, transmission mode 3, transmission mode 7 and
transmission mode 8 configured without PMI/RI reporting). */
typedef struct LIBLTE_API {
uint8_t wideband_cqi; // 4-bit width
uint32_t subband_diff_cqi; // 2N-bit width
} cqi_hl_subband_t;
/* Table 5.2.2.6.3-1: Fields for channel quality information feedback for UE selected subband CQI
reports
(transmission mode 1, transmission mode 2, transmission mode 3, transmission mode 7 and
transmission mode 8 configured without PMI/RI reporting). */
typedef struct LIBLTE_API {
uint8_t wideband_cqi; // 4-bit width
uint8_t subband_diff_cqi; // 2-bit width
uint32_t position_subband; // L-bit width
} cqi_ue_subband_t;
LIBLTE_API void cqi_hl_subband_pack(cqi_hl_subband_t *msg,
uint32_t N,
uint8_t *buff,
uint32_t buff_len);
LIBLTE_API void cqi_ue_subband_pack(cqi_hl_subband_t *msg,
uint32_t L,
uint8_t *buff,
uint32_t buff_len);
#endif // CQI_

View File

@ -64,6 +64,9 @@ typedef struct LIBLTE_API {
tdec_t decoder;
crc_t crc_tb;
crc_t crc_cb;
uci_cqi_t uci_cqi;
} sch_t;
LIBLTE_API int sch_init(sch_t *q);
@ -92,6 +95,13 @@ LIBLTE_API int dlsch_decode(sch_t *q,
uint32_t rv_idx);
LIBLTE_API int ulsch_encode(sch_t *q,
uint8_t *data,
uint8_t *q_bits,
uint32_t nb_q,
harq_t *harq_process,
uint32_t rv_idx);
LIBLTE_API int ulsch_uci_encode(sch_t *q,
uint8_t *data,
uci_data_t uci_data,
uint8_t *q_bits,

View File

@ -32,6 +32,15 @@
#include "liblte/config.h"
#include "liblte/phy/common/phy_common.h"
#include "liblte/phy/phch/harq.h"
#include "liblte/phy/fec/crc.h"
#define MAX_CQI_LEN 512
typedef struct LIBLTE_API {
crc_t crc;
uint8_t tmp_cqi[MAX_CQI_LEN];
uint8_t encoded_cqi[3*MAX_CQI_LEN];
} uci_cqi_t;
typedef struct LIBLTE_API {
uint8_t *uci_cqi;
@ -45,16 +54,22 @@ typedef struct LIBLTE_API {
float beta_ack;
} uci_data_t;
LIBLTE_API int uci_cqi_init(uci_cqi_t *q);
LIBLTE_API int uci_encode_cqi(uint8_t *data,
uint8_t *e_bits,
uint32_t tbs,
uint32_t nb_e);
LIBLTE_API void uci_cqi_free(uci_cqi_t *q);
LIBLTE_API int uci_encode_cqi(uci_cqi_t *q,
uint8_t *cqi_data,
uint32_t cqi_len,
float beta,
uint32_t Q_prime_ri,
harq_t *harq_process,
uint8_t *q_bits);
/* Encode UCI RI and HARQ ACK/NACK bits */
LIBLTE_API uint32_t uci_encode_ri_ack(uint8_t data,
LIBLTE_API int uci_encode_ri_ack(uint8_t data,
float beta,
uint8_t q_bits[6],
harq_t *harq_process);
harq_t *harq_process,
uint8_t q_bits[6]);
#endif

View File

@ -0,0 +1,57 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2014 The libLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the libLTE library.
*
* libLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* libLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* A copy of the GNU Lesser General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <math.h>
#include "liblte/phy/phch/cqi.h"
#include "liblte/phy/common/phy_common.h"
#include "liblte/phy/utils/bit.h"
#include "liblte/phy/utils/vector.h"
#include "liblte/phy/utils/debug.h"
void cqi_hl_subband_pack(cqi_hl_subband_t *msg, uint32_t N, uint8_t *buff, uint32_t buff_len)
{
uint8_t *body_ptr = buff;
bit_pack(msg->wideband_cqi, &body_ptr, 4);
bit_pack(msg->subband_diff_cqi, &body_ptr, 2*N);
}
void cqi_ue_subband_pack(cqi_ue_subband_t *msg, uint32_t L, uint8_t *buff, uint32_t buff_len)
{
uint8_t *body_ptr = buff;
bit_pack(msg->wideband_cqi, &body_ptr, 4);
bit_pack(msg->subband_diff_cqi, &body_ptr, 2);
bit_pack(msg->subband_diff_cqi, &body_ptr, L);
}

View File

@ -174,6 +174,12 @@ void pusch_free(pusch_t *q) {
if (q->pusch_d) {
free(q->pusch_d);
}
if (q->pusch_q_ack) {
free(q->pusch_q_ack);
}
if (q->pusch_q_ri) {
free(q->pusch_q_ri);
}
for (i = 0; i < q->cell.nof_ports; i++) {
if (q->ce[i]) {
free(q->ce[i]);
@ -348,7 +354,7 @@ 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));
if (ulsch_encode(&q->dl_sch, data, uci_data, q->pusch_e, nof_bits_e,
if (ulsch_uci_encode(&q->dl_sch, data, uci_data, q->pusch_e, nof_bits_e,
q->pusch_q_ack, q->pusch_q_ri, harq_process, rv_idx))
{
fprintf(stderr, "Error encoding TB\n");

View File

@ -76,6 +76,10 @@ int sch_init(sch_t *q) {
if (!q->cb_out) {
goto clean;
}
if (uci_cqi_init(&q->uci_cqi)) {
goto clean;
}
ret = LIBLTE_SUCCESS;
}
clean:
@ -94,7 +98,7 @@ void sch_free(sch_t *q) {
}
tdec_free(&q->decoder);
tcod_free(&q->encoder);
uci_cqi_free(&q->uci_cqi);
bzero(q, sizeof(sch_t));
}
@ -404,8 +408,8 @@ uint8_t ulsch_y_mat[10000];
/* UL-SCH channel interleaver according to 5.5.2.8 of 36.212 */
void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
uint8_t q_bits_ack[6], uint32_t Q_ack,
uint8_t q_bits_ri[6], uint32_t Q_ri,
uint8_t q_bits_ack[6], uint32_t Q_prime_ack,
uint8_t q_bits_ri[6], uint32_t Q_prime_ri,
uint32_t Q_m)
{
uint32_t C_mux;
@ -429,12 +433,13 @@ void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
// Step 2: Define R_mux and R_prime_mux
H_prime = nb_q;
H_prime_total = H_prime + Q_ri;
H_prime_total = H_prime + Q_prime_ri;
R_mux = (H_prime_total*Q_m)/C_mux;
R_prime_mux = R_mux/Q_m;
// Initialize the matricies
//printf("Cmux*R_prime=%d*%d=%d\n",C_mux, R_prime_mux, C_mux*R_prime_mux);
printf("Cmux*R_prime=%d*%d=%d, H_prime=%d, H_prime_total=%d\n",C_mux, R_prime_mux, C_mux*R_prime_mux, H_prime, H_prime_total);
for(i=0; i<C_mux*R_prime_mux; i++) {
ulsch_y_idx[i] = 100;
}
@ -446,7 +451,7 @@ void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
i = 0;
j = 0;
r = R_prime_mux-1;
while(i < Q_ri) {
while(i < Q_prime_ri) {
C_ri = ri_column_set[j];
ulsch_y_idx[r*C_mux + C_ri] = 1;
for(k=0; k<Q_m; k++) {
@ -456,6 +461,7 @@ void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
r = R_prime_mux - 1 - i/4;
j = (j + 3) % 4;
}
printf("H_prime: %d, C_mux: %d, R_prime: %d\n", H_prime, C_mux, R_prime_mux);
// Step 4: Interleave the data bits
i = 0;
@ -475,7 +481,7 @@ void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
i = 0;
j = 0;
r = R_prime_mux-1;
while(i < Q_ack/Q_m) {
while(i < Q_prime_ack) {
C_ack = ack_column_set[j];
ulsch_y_idx[r*C_mux + C_ack] = 2;
for(k=0; k<Q_m; k++) {
@ -488,6 +494,7 @@ void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
// Step 6: Read out the bits
idx = 0;
printf("go for C_mux: %d, R_prime: %d, Q_m: %d\n", C_mux, R_prime_mux, Q_m);
for(i=0; i<C_mux; i++) {
for(j=0; j<R_prime_mux; j++) {
for(k=0; k<Q_m; k++) {
@ -499,49 +506,78 @@ void ulsch_interleave(uint8_t *q_bits, uint32_t nb_q,
}
int ulsch_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *q_bits, uint32_t nb_q,
int ulsch_encode(sch_t *q, uint8_t *data, uint8_t *q_bits, uint32_t nb_q,
harq_t *harq_process, uint32_t rv_idx)
{
uci_data_t uci_data;
bzero(&uci_data, sizeof(uci_data_t));
return ulsch_uci_encode(q, data, uci_data, q_bits, nb_q, NULL, NULL, harq_process, rv_idx);
}
int ulsch_uci_encode(sch_t *q, uint8_t *data, uci_data_t uci_data, uint8_t *q_bits, uint32_t nb_q,
uint8_t *q_bits_ack, uint8_t *q_bits_ri,
harq_t *harq_process, uint32_t rv_idx)
{
int ret;
uint32_t e_offset = 0;
uint32_t Q_prime_cqi = 0;
uint32_t Q_prime_ack = 0;
uint32_t Q_prime_ri = 0;
uint32_t Q_m = lte_mod_bits_x_symbol(harq_process->mcs.mod);
// Encode CQI
if (uci_data.uci_cqi_len > 0) {
ret = uci_encode_cqi(uci_data.uci_cqi, q_bits, uci_data.uci_cqi_len, nb_q);
if (ret) {
return ret;
}
}
e_offset += uci_data.uci_cqi_len;
// Encode UL-SCH
ret = encode_tb(q, data, &q_bits[e_offset], harq_process->mcs.tbs,
nb_q, harq_process, rv_idx);
if (ret) {
return ret;
}
// Encode ACK
if (uci_data.uci_ack_len > 0) {
Q_prime_ack = uci_encode_ri_ack(uci_data.uci_ack, uci_data.beta_ack, q_bits_ack, harq_process);
ret = uci_encode_ri_ack(uci_data.uci_ack, uci_data.beta_ack, harq_process, q_bits_ack);
if (ret < 0) {
return ret;
}
Q_prime_ack = (uint32_t) ret;
}
// Encode RI
if (uci_data.uci_ri_len > 0) {
Q_prime_ri = uci_encode_ri_ack(uci_data.uci_ri, uci_data.beta_ri, q_bits_ri, harq_process);
ret = uci_encode_ri_ack(uci_data.uci_ri, uci_data.beta_ri, harq_process, q_bits_ri);
if (ret < 0) {
return ret;
}
Q_prime_ri = (uint32_t) ret;
}
// Encode CQI
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,
Q_prime_ri, harq_process, q_bits);
if (ret < 0) {
return ret;
}
Q_prime_cqi = (uint32_t) ret;
}
e_offset += Q_prime_cqi*Q_m;
uint32_t G = nb_q/Q_m - Q_prime_ri - Q_prime_cqi;
printf("Offset: %d*%d=%d, G*Q_m=%d*%d=%d, n_bq=%d Q_prime_cq=%d\n",Q_prime_cqi, Q_m, e_offset, G, Q_m, G*Q_m, nb_q, Q_prime_cqi);
// Encode UL-SCH
ret = encode_tb(q, data, &q_bits[e_offset], harq_process->mcs.tbs,
G*Q_m, harq_process, rv_idx);
if (ret) {
return ret;
}
// Multiplexing and Interleaving
ulsch_interleave(q_bits, nb_q/Q_m,
ulsch_interleave(q_bits, nb_q/Q_m-Q_prime_ri,
q_bits_ack, Q_prime_ack,
q_bits_ri, Q_prime_ri,
Q_m);
return LIBLTE_SUCCESS;
}

View File

@ -36,18 +36,163 @@
#include "liblte/phy/phch/uci.h"
#include "liblte/phy/phch/harq.h"
#include "liblte/phy/fec/convcoder.h"
#include "liblte/phy/fec/crc.h"
#include "liblte/phy/fec/rm_conv.h"
#include "liblte/phy/common/phy_common.h"
#include "liblte/phy/utils/vector.h"
#include "liblte/phy/utils/debug.h"
/* Table 5.2.2.6.4-1: Basis sequence for (32, O) code */
static uint8_t M_basis_seq[32][11]={
{1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 },
{1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 },
{1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1 },
{1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 },
{1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 },
{1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1 },
{1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1 },
{1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1 },
{1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1 },
{1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1 },
{1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1 },
{1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1 },
{1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1 },
{1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1 },
{1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1 },
{1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0 },
{1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0 },
{1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0 },
{1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 },
{1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 },
{1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1 },
{1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1 },
{1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1 },
{1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0 },
{1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1 },
{1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0 },
{1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0 },
{1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0 },
{1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0 },
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
};
/* Encode UCI-CQI */
int uci_encode_cqi(uint8_t *data, uint8_t *e_bits, uint32_t tbs, uint32_t nb_e)
{
fprintf(stderr, "Not implemented\n");
return -1;
int uci_cqi_init(uci_cqi_t *q) {
printf("init\n");
if (crc_init(&q->crc, LTE_CRC8, 8)) {
return LIBLTE_ERROR;
}
return LIBLTE_SUCCESS;
}
static uint32_t Q_prime(uint32_t O, float beta, harq_t *harq_process) {
void uci_cqi_free(uci_cqi_t *q) {
}
static uint32_t Q_prime_cqi(uint32_t O, float beta, uint32_t Q_prime_ri, harq_t *harq_process) {
uint32_t M_sc = harq_process->prb_alloc.slot[0].nof_prb * RE_X_RB;
uint32_t K = harq_process->cb_segm.C1*harq_process->cb_segm.K1 +
harq_process->cb_segm.C2*harq_process->cb_segm.K2;
uint32_t M_sc_init = harq_process->nof_prb_pusch_init * RE_X_RB;
uint32_t L = (O<11)?0:8;
uint32_t x = (uint32_t) ceilf((float) (O+L)*M_sc_init*harq_process->N_symb_ul*beta/K);
uint32_t Q_prime = MIN(x, M_sc * harq_process->N_symb_ul - Q_prime_ri);
return Q_prime;
}
/* Encode UCI CQI/PMI for payloads equal or lower to 11 bits (Sec 5.2.2.6.4)
*/
int encode_cqi_short(uci_cqi_t *q, uint8_t *data, uint32_t nof_bits, uint8_t *q_bits, uint32_t Q)
{
if (nof_bits < MAX_CQI_LEN &&
q != NULL &&
data != NULL &&
q_bits != NULL)
{
for (int i=0;i<32;i++) {
q->encoded_cqi[i] = 0;
for (int n=0;n<nof_bits;n++) {
q->encoded_cqi[i] += (data[n] * M_basis_seq[i][n]) % 2;
}
}
for (int i=0;i<Q;i++) {
q_bits[i] = q->encoded_cqi[i%32];
}
return LIBLTE_SUCCESS;
} else {
return LIBLTE_ERROR_INVALID_INPUTS;
}
}
/* Encode UCI CQI/PMI for payloads greater than 11 bits (go through CRC, conv coder and rate match)
*/
int encode_cqi_long(uci_cqi_t *q, uint8_t *data, uint32_t nof_bits, uint8_t *q_bits, uint32_t Q)
{
convcoder_t encoder;
if (nof_bits + 8 < MAX_CQI_LEN &&
q != NULL &&
data != NULL &&
q_bits != NULL)
{
int poly[3] = { 0x6D, 0x4F, 0x57 };
encoder.K = 7;
encoder.R = 3;
encoder.tail_biting = true;
memcpy(encoder.poly, poly, 3 * sizeof(int));
memcpy(q->tmp_cqi, data, sizeof(uint8_t) * nof_bits);
crc_attach(&q->crc, q->tmp_cqi, nof_bits);
convcoder_encode(&encoder, q->tmp_cqi, q->encoded_cqi, nof_bits + 8);
DEBUG("CConv output: ", 0);
if (VERBOSE_ISDEBUG()) {
vec_fprint_b(stdout, q->encoded_cqi, 3 * (nof_bits + 8));
}
printf("rm to Q=%d\n", Q);
rm_conv_tx(q->encoded_cqi, 3 * (nof_bits + 8), q_bits, Q);
return LIBLTE_SUCCESS;
} else {
return LIBLTE_ERROR_INVALID_INPUTS;
}
}
/* Encode UCI CQI/PMI as described in 5.2.2.6 of 36.212
*/
int uci_encode_cqi(uci_cqi_t *q, uint8_t *cqi_data, uint32_t cqi_len, float beta, uint32_t Q_prime_ri,
harq_t *harq_process, uint8_t *q_bits)
{
uint32_t Q_prime = Q_prime_cqi(cqi_len, beta, Q_prime_ri, harq_process);
uint32_t Q_m = lte_mod_bits_x_symbol(harq_process->mcs.mod);
printf("Q_prime_cqi: %d\n", Q_prime);
int ret = LIBLTE_ERROR;
if (cqi_len <= 11) {
ret = encode_cqi_short(q, cqi_data, cqi_len, q_bits, Q_prime*Q_m);
} else {
ret = encode_cqi_long(q, cqi_data, cqi_len, q_bits, Q_prime*Q_m);
}
if (ret) {
return ret;
} else {
return (int) Q_prime;
}
}
static uint32_t Q_prime_ri_ack(uint32_t O, float beta, harq_t *harq_process) {
uint32_t M_sc = harq_process->prb_alloc.slot[0].nof_prb * RE_X_RB;
uint32_t K = harq_process->cb_segm.C1*harq_process->cb_segm.K1 +
@ -56,34 +201,30 @@ static uint32_t Q_prime(uint32_t O, float beta, harq_t *harq_process) {
uint32_t x = (uint32_t) ceilf((float) O*M_sc_init*harq_process->N_symb_ul*beta/K);
printf("%d=%d*%d*%d*%f/%d\n",x,O,M_sc_init,harq_process->N_symb_ul,beta,K);
uint32_t Q_prime = MIN(x, 4*M_sc);
return Q_prime;
}
/* Encode UCI RI and HARQ bits
/* Encode UCI RI and HARQ bits as described in 5.2.2.6 of 36.212
* Currently only supporting 1-bit RI or 1-bit HARQ
*/
uint32_t uci_encode_ri_ack(uint8_t data, float beta, uint8_t *q_bits, harq_t *harq_process)
int uci_encode_ri_ack(uint8_t data, float beta, harq_t *harq_process, uint8_t *q_bits)
{
uint8_t Q_m = lte_mod_bits_x_symbol(harq_process->mcs.mod);
uint32_t Q_m = lte_mod_bits_x_symbol(harq_process->mcs.mod);
q_bits[0] = data;
q_bits[1] = 2;
for (int i=2;i<Q_m;i++) {
for (uint32_t i=2;i<Q_m;i++) {
q_bits[i] = 3;
}
uint32_t Qprime = Q_prime(1, beta, harq_process);
uint32_t Qprime = Q_prime_ri_ack(1, beta, harq_process);
for (int i=1;i<Qprime;i++) {
for (uint32_t i=1;i<Qprime;i++) {
memcpy(&q_bits[i*Q_m], q_bits, Q_m*sizeof(uint8_t));
}
printf("Q_m: %d, Qprime: %d, beta: %f\n", Q_m, Qprime, beta);
return Qprime * Q_m;
return (int) Qprime;
}

View File

@ -129,7 +129,7 @@ int main(int argc, char **argv) {
ra_mcs_t mcs;
ra_prb_t prb_alloc;
harq_t harq_process;
uint32_t rv;
uint32_t rv = 0;
parse_args(argc,argv);
@ -184,31 +184,40 @@ int main(int argc, char **argv) {
}
for (i=0;i<mcs.tbs;i++) {
data[i] = rand()%2;
data[i] = 1;
}
printf("INPUT: ");
vec_fprint_b(stdout, data, mcs.tbs);
for (rv=0;rv<=rv_idx;rv++) {
printf("Encoding rv_idx=%d\n",rv);
uint8_t tmp[20];
for (i=0;i<20;i++) {
tmp[i] = 1;
}
uci_data_t uci_data;
bzero(&uci_data, sizeof(uci_data_t));
uci_data.beta_cqi = 2.0;
uci_data.beta_ri = 2.0;
uci_data.beta_ack = 2.0;
uci_data.uci_ack = 1;
uci_data.uci_ack_len = 1;
uci_data.uci_cqi = tmp;
uci_data.uci_cqi_len = 20;
uci_data.uci_ri_len = 0;
uci_data.uci_ack_len = 0;
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);
if (ulsch_encode(&pusch.dl_sch, data, uci_data, pusch.pusch_e, nof_bits_e,
if (ulsch_uci_encode(&pusch.dl_sch, data, uci_data, pusch.pusch_e, nof_bits_e,
pusch.pusch_q_ack, pusch.pusch_q_ri, &harq_process, rv))
{
fprintf(stderr, "Error encoding TB\n");
exit(-1);
}
vec_fprint_b(stdout, pusch.pusch_e, 288);
vec_fprint_b(stdout, pusch.pusch_e, nof_bits_e);
/* combine outputs */
for (i=0;i<cell.nof_ports;i++) {

View File

@ -67,6 +67,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
lte_cell_t cell;
cell.nof_prb = 100;
cell.id=1;
cell.cp=CPNORM;
if (harq_init(&harq_process, cell)) {
mexErrMsgTxt("Error initiating HARQ\n");
return;
@ -146,6 +147,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
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);
if (harq_setup(&harq_process, mcs, &prb_alloc)) {
mexErrMsgTxt("Error configuring HARQ process\n");
return;
@ -154,6 +157,8 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
uint32_t nof_symbols = 12*harq_process.prb_alloc.slot[0].nof_prb*RE_X_RB;
uint32_t nof_q_bits = nof_symbols * lte_mod_bits_x_symbol(harq_process.mcs.mod);
printf("alloc for %d bits\n", nof_q_bits);
uint8_t *q_bits = vec_malloc(nof_q_bits * sizeof(uint8_t));
if (!q_bits) {
return;
@ -167,10 +172,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
return;
}
if (ulsch_encode(&ulsch, trblkin, uci_data, q_bits, nof_q_bits,
if (ulsch_uci_encode(&ulsch, trblkin, uci_data, q_bits, nof_q_bits,
q_bits_ack, q_bits_ri, &harq_process, rv))
{
fprintf(stderr, "Error encoding TB\n");
mexErrMsgTxt("Error encoding TB\n");
return;
}
@ -185,6 +190,10 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
free(q_bits_ack);
free(q_bits_ri);
if (uci_data.uci_cqi_len > 0) {
free(uci_data.uci_cqi);
}
return;
}

Binary file not shown.

View File

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