diff --git a/lte/phy/include/liblte/phy/filter/dft_precoding.h b/lte/phy/include/liblte/phy/filter/dft_precoding.h index cd0f9a514..a25e7f3ac 100644 --- a/lte/phy/include/liblte/phy/filter/dft_precoding.h +++ b/lte/phy/include/liblte/phy/filter/dft_precoding.h @@ -49,6 +49,8 @@ LIBLTE_API int dft_precoding_init(dft_precoding_t *q, LIBLTE_API void dft_precoding_free(dft_precoding_t *q); +LIBLTE_API bool dft_precoding_valid_prb(uint32_t nof_prb); + LIBLTE_API int dft_precoding(dft_precoding_t *q, cf_t *input, cf_t *output, diff --git a/lte/phy/include/liblte/phy/phch/ra.h b/lte/phy/include/liblte/phy/phch/ra.h index 98e8eca09..816600466 100644 --- a/lte/phy/include/liblte/phy/phch/ra.h +++ b/lte/phy/include/liblte/phy/phch/ra.h @@ -130,7 +130,7 @@ LIBLTE_API int ra_prb_get_dl(ra_prb_t *prb, ra_pdsch_t *ra, uint32_t nof_prb); -LIBLTE_API int ra_prb_get_ul(ra_prb_slot_t *prb, +LIBLTE_API int ra_prb_get_ul(ra_prb_t *prb, ra_pusch_t *ra, uint32_t nof_prb); @@ -141,10 +141,10 @@ LIBLTE_API void ra_prb_get_re_dl(ra_prb_t *prb_dist, lte_cp_t cp); LIBLTE_API uint32_t ra_nprb_dl(ra_pdsch_t *ra, - uint32_t nof_prb); + uint32_t nof_prb); LIBLTE_API uint32_t ra_nprb_ul(ra_pusch_t *ra, - uint32_t nof_prb); + uint32_t nof_prb); LIBLTE_API int ra_mcs_from_idx_dl(uint32_t mcs_idx, uint32_t nof_prb, diff --git a/lte/phy/lib/ch_estimation/src/refsignal_ul.c b/lte/phy/lib/ch_estimation/src/refsignal_ul.c index aa951a9b4..a05299f0e 100644 --- a/lte/phy/lib/ch_estimation/src/refsignal_ul.c +++ b/lte/phy/lib/ch_estimation/src/refsignal_ul.c @@ -284,7 +284,7 @@ int refsignal_dmrs_pusch_gen(refsignal_ul_t *q, refsignal_drms_pusch_cfg_t *cfg, for (int i=0;inof_prb;i++) { r_pusch[i] = cfg->beta_pusch * cexpf(I*(q->tmp_arg[i] + alpha*i)); } - vec_fprint_c(stdout, r_pusch, RE_X_RB*cfg->nof_prb); + vec_fprint_c(stdout, r_pusch, RE_X_RB*cfg->nof_prb); ret = 0; } return ret; diff --git a/lte/phy/lib/filter/src/dft_precoding.c b/lte/phy/lib/filter/src/dft_precoding.c index 9d5730740..de3500028 100644 --- a/lte/phy/lib/filter/src/dft_precoding.c +++ b/lte/phy/lib/filter/src/dft_precoding.c @@ -46,18 +46,21 @@ int dft_precoding_init(dft_precoding_t *q, uint32_t max_prb) int ret = LIBLTE_ERROR_INVALID_INPUTS; bzero(q, sizeof(dft_precoding_t)); - if (max_prb >= MAX_PRB) { + if (max_prb <= MAX_PRB) { ret = LIBLTE_ERROR; - for (uint32_t i=0;idft_plan[i], i*RE_X_RB, FORWARD)) { fprintf(stderr, "Error: Creating DFT plan %d\n",i); goto clean_exit; } + dft_plan_set_norm(&q->dft_plan[i], true); if (dft_plan_c(&q->idft_plan[i], i*RE_X_RB, BACKWARD)) { fprintf(stderr, "Error: Creating DFT plan %d\n",i); goto clean_exit; - } + } + dft_plan_set_norm(&q->idft_plan[i], true); } } q->max_prb = max_prb; @@ -74,8 +77,9 @@ clean_exit: /* Free DFT plans for transform precoding */ void dft_precoding_free(dft_precoding_t *q) { - for (uint32_t i=0;imax_prb;i++) { - if((i % 2) == 0 || (i % 3) == 0 || (i % 5) == 0) { + for (uint32_t i=2;imax_prb;i++) { + if(dft_precoding_valid_prb(i)) { + DEBUG("Freeing DFT precoding plan for %d PRBs\n", i); dft_plan_free(&q->dft_plan[i]); dft_plan_free(&q->idft_plan[i]); } @@ -83,11 +87,19 @@ void dft_precoding_free(dft_precoding_t *q) bzero(q, sizeof(dft_precoding_t)); } +bool dft_precoding_valid_prb(uint32_t nof_prb) { + if ((nof_prb%2) == 0 || (nof_prb%3) == 0 || (nof_prb%5) == 0) { + return true; + } else { + return false; + } +} + int dft_precoding(dft_precoding_t *q, cf_t *input, cf_t *output, uint32_t nof_prb, uint32_t nof_symbols) { - if ((nof_prb%2) || (nof_prb%3) || (nof_prb%5)) { + if (!dft_precoding_valid_prb(nof_prb)) { fprintf(stderr, "Error invalid number of PRB (%d)\n", nof_prb); return LIBLTE_ERROR; } @@ -102,7 +114,7 @@ int dft_precoding(dft_precoding_t *q, cf_t *input, cf_t *output, int dft_predecoding(dft_precoding_t *q, cf_t *input, cf_t *output, uint32_t nof_prb, uint32_t nof_symbols) { - if ((nof_prb%2) || (nof_prb%3) || (nof_prb%5)) { + if (!dft_precoding_valid_prb(nof_prb)) { fprintf(stderr, "Error invalid number of PRB (%d)\n", nof_prb); return LIBLTE_ERROR; } diff --git a/lte/phy/lib/phch/src/pbch.c b/lte/phy/lib/phch/src/pbch.c index 4dd07bae9..b251882de 100644 --- a/lte/phy/lib/phch/src/pbch.c +++ b/lte/phy/lib/phch/src/pbch.c @@ -34,7 +34,7 @@ #include #include -#include "prb.h" +#include "prb_dl.h" #include "liblte/phy/phch/pbch.h" #include "liblte/phy/common/phy_common.h" #include "liblte/phy/utils/bit.h" diff --git a/lte/phy/lib/phch/src/pdsch.c b/lte/phy/lib/phch/src/pdsch.c index 6f7fac6da..0a9e480a4 100644 --- a/lte/phy/lib/phch/src/pdsch.c +++ b/lte/phy/lib/phch/src/pdsch.c @@ -34,7 +34,7 @@ #include #include -#include "prb.h" +#include "prb_dl.h" #include "liblte/phy/phch/pdsch.h" #include "liblte/phy/common/phy_common.h" #include "liblte/phy/utils/bit.h" diff --git a/lte/phy/lib/phch/src/phich.c b/lte/phy/lib/phch/src/phich.c index d039a7de9..e628d9dbc 100644 --- a/lte/phy/lib/phch/src/phich.c +++ b/lte/phy/lib/phch/src/phich.c @@ -34,7 +34,6 @@ #include #include -#include "prb.h" #include "liblte/phy/phch/regs.h" #include "liblte/phy/phch/phich.h" #include "liblte/phy/common/phy_common.h" diff --git a/lte/phy/lib/phch/src/prb.c b/lte/phy/lib/phch/src/prb_dl.c similarity index 99% rename from lte/phy/lib/phch/src/prb.c rename to lte/phy/lib/phch/src/prb_dl.c index 85414d2e9..51e31c28c 100644 --- a/lte/phy/lib/phch/src/prb.c +++ b/lte/phy/lib/phch/src/prb_dl.c @@ -29,7 +29,7 @@ #include #include -#include "prb.h" +#include "prb_dl.h" #include "liblte/phy/common/phy_common.h" //#define DEBUG_IDX diff --git a/lte/phy/lib/phch/src/prb.h b/lte/phy/lib/phch/src/prb_dl.h similarity index 92% rename from lte/phy/lib/phch/src/prb.h rename to lte/phy/lib/phch/src/prb_dl.h index 0ca10fd5a..3aea25003 100644 --- a/lte/phy/lib/phch/src/prb.h +++ b/lte/phy/lib/phch/src/prb_dl.h @@ -34,5 +34,3 @@ void prb_cp(cf_t **input, cf_t **output, int nof_prb); void prb_cp_half(cf_t **input, cf_t **output, int nof_prb); void prb_put_ref_(cf_t **input, cf_t **output, int offset, int nof_refs, int nof_intervals); -void phch_get_prb_ref(cf_t **input, cf_t **output, int offset, int nof_refs, - int nof_intervals); diff --git a/lte/phy/lib/phch/src/pusch.c b/lte/phy/lib/phch/src/pusch.c index bb0888260..8d282f28a 100644 --- a/lte/phy/lib/phch/src/pusch.c +++ b/lte/phy/lib/phch/src/pusch.c @@ -34,7 +34,6 @@ #include #include -#include "prb.h" #include "liblte/phy/phch/pusch.h" #include "liblte/phy/phch/uci.h" #include "liblte/phy/common/phy_common.h" @@ -50,45 +49,50 @@ const static lte_mod_t modulations[4] = { LTE_BPSK, LTE_QPSK, LTE_QAM16, LTE_QAM64 }; -//#define DEBUG_IDX - -#ifdef DEBUG_IDX -cf_t *offset_original=NULL; -extern int indices[100000]; -extern int indices_ptr; -#endif - - -int pusch_cp(pusch_t *q, cf_t *input, cf_t *output, ra_prb_t *prb_alloc, - uint32_t nsubframe, bool put) +int pusch_cp(pusch_t *q, ra_prb_t *prb_alloc, cf_t *input, cf_t *output, bool advance_input) { - return -1; + cf_t *in_ptr = input; + cf_t *out_ptr = output; + + uint32_t L_ref = 3; + if (CP_ISEXT(q->cell.cp)) { + L_ref = 2; + } + + for (uint32_t slot=0;slot<2;slot++) { + for (uint32_t l=0;lcell.cp);l++) { + if (l != L_ref) { + for (uint32_t n=0;ncell.nof_prb;n++) { + if (prb_alloc->slot[slot].prb_idx[n]) { + uint32_t idx = RE_IDX(q->cell.nof_prb, l+slot*CP_NSYMB(q->cell.cp), n*RE_X_RB); + if (advance_input) { + out_ptr = &output[idx]; + } else { + in_ptr = &input[idx]; + } + memcpy(out_ptr, in_ptr, RE_X_RB * sizeof(cf_t)); + if (advance_input) { + in_ptr += RE_X_RB; + } else { + out_ptr += RE_X_RB; + } + } + } + } + } + } + return RE_X_RB*prb_alloc->slot[0].nof_prb; } -/** - * Puts PUSCH in slot number 1 - * - * Returns the number of symbols written to sf_symbols - * - * 36.211 10.3 section 6.3.5 - */ -int pusch_put(pusch_t *q, cf_t *pusch_symbols, cf_t *sf_symbols, - ra_prb_t *prb_alloc, uint32_t subframe) { - return pusch_cp(q, pusch_symbols, sf_symbols, prb_alloc, subframe, true); +int pusch_put(pusch_t *q, ra_prb_t *prb_alloc, cf_t *input, cf_t *output) { + return pusch_cp(q, prb_alloc, input, output, true); } -/** - * Extracts PUSCH from slot number 1 - * - * Returns the number of symbols written to PUSCH - * - * 36.211 10.3 section 6.3.5 - */ -int pusch_get(pusch_t *q, cf_t *sf_symbols, cf_t *pusch_symbols, - ra_prb_t *prb_alloc, uint32_t subframe) { - return pusch_cp(q, sf_symbols, pusch_symbols, prb_alloc, subframe, false); +int pusch_get(pusch_t *q, ra_prb_t *prb_alloc, cf_t *input, cf_t *output) { + return pusch_cp(q, prb_alloc, input, output, false); } + /** Initializes the PDCCH transmitter and receiver */ int pusch_init(pusch_t *q, lte_cell_t cell) { int ret = LIBLTE_ERROR_INVALID_INPUTS; @@ -118,7 +122,10 @@ int pusch_init(pusch_t *q, lte_cell_t cell) { sch_init(&q->dl_sch); - dft_precoding_init(&q->dft_precoding, cell.nof_prb); + if (dft_precoding_init(&q->dft_precoding, cell.nof_prb)) { + fprintf(stderr, "Error initiating DFT transform precoding\n"); + goto clean; + } /* This is for equalization at receiver */ if (precoding_init(&q->equalizer, SF_LEN_RE(cell.nof_prb, cell.cp))) { @@ -232,14 +239,14 @@ int pusch_decode(pusch_t *q, harq_t *harq, cf_t *sf_symbols, cf_t *ce, float noi harq->sf_idx, lte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); /* extract symbols */ - n = pusch_get(q, sf_symbols, q->pusch_d, &harq->prb_alloc, harq->sf_idx); + n = pusch_get(q, &harq->prb_alloc, sf_symbols, q->pusch_d); if (n != harq->nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", harq->nof_re, n); return LIBLTE_ERROR; } /* extract channel estimates */ - n = pusch_get(q, ce, q->ce, &harq->prb_alloc, harq->sf_idx); + n = pusch_get(q, &harq->prb_alloc, ce, q->ce); if (n != harq->nof_re) { fprintf(stderr, "Error expecting %d symbols but got %d\n", harq->nof_re, n); return LIBLTE_ERROR; @@ -291,18 +298,13 @@ int pusch_uci_encode(pusch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_dat { if (q->rnti_is_set) { - if (harq->mcs.tbs == 0) { - return LIBLTE_ERROR_INVALID_INPUTS; - } - if (harq->mcs.tbs > harq->nof_bits) { fprintf(stderr, "Invalid code rate %.2f\n", (float) harq->mcs.tbs / harq->nof_bits); return LIBLTE_ERROR_INVALID_INPUTS; } if (harq->nof_re > q->max_re) { - fprintf(stderr, - "Error too many RE per subframe (%d). PUSCH configured for %d RE (%d PRB)\n", + fprintf(stderr, "Error too many RE per subframe (%d). PUSCH configured for %d RE (%d PRB)\n", harq->nof_re, q->max_re, q->cell.nof_prb); return LIBLTE_ERROR_INVALID_INPUTS; } @@ -310,8 +312,7 @@ int pusch_uci_encode(pusch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_dat INFO("Encoding PUSCH SF: %d, Mod %s, TBS: %d, NofSymbols: %d, NofBitsE: %d, rv_idx: %d\n", harq->sf_idx, lte_mod_string(harq->mcs.mod), harq->mcs.tbs, harq->nof_re, harq->nof_bits, harq->rv); - if (ulsch_uci_encode(&q->dl_sch, harq, data, uci_data, q->pusch_g, q->pusch_q)) - { + if (ulsch_uci_encode(&q->dl_sch, harq, data, uci_data, q->pusch_g, q->pusch_q)) { fprintf(stderr, "Error encoding TB\n"); return LIBLTE_ERROR; } @@ -324,7 +325,7 @@ int pusch_uci_encode(pusch_t *q, harq_t *harq, uint8_t *data, uci_data_t uci_dat harq->prb_alloc.slot[0].nof_prb, harq->nof_symb); /* mapping to resource elements */ - pusch_put(q, q->pusch_z, sf_symbols, &harq->prb_alloc, harq->sf_idx); + pusch_put(q, &harq->prb_alloc, q->pusch_z, sf_symbols); ret = LIBLTE_SUCCESS; } else { diff --git a/lte/phy/lib/phch/src/ra.c b/lte/phy/lib/phch/src/ra.c index 2f0f48aea..de1a015a6 100644 --- a/lte/phy/lib/phch/src/ra.c +++ b/lte/phy/lib/phch/src/ra.c @@ -143,15 +143,23 @@ void ra_prb_fprint(FILE *f, ra_prb_slot_t *prb, uint32_t nof_prb) { } /** Compute PRB allocation for Uplink as defined in 8.1 of 36.213 */ -int ra_prb_get_ul(ra_prb_slot_t *prb, ra_pusch_t *ra, uint32_t nof_prb) { +int ra_prb_get_ul(ra_prb_t *prb_dist, ra_pusch_t *ra, uint32_t nof_prb) { int i; if (ra->type2_alloc.mode != t2_loc) { fprintf(stderr, "Uplink only accepts type2 localized scheduling\n"); return LIBLTE_ERROR; } - for (i = 0; i < ra->type2_alloc.L_crb; i++) { - prb->prb_idx[i] = i + ra->type2_alloc.RB_start; - prb->nof_prb++; + bzero(prb_dist, sizeof(ra_prb_t)); + + switch (ra->freq_hop_fl) { + case hop_disabled: + for (i = 0; i < ra->type2_alloc.L_crb; i++) { + prb_dist->slot[0].prb_idx[i + ra->type2_alloc.RB_start] = true; + prb_dist->slot[0].nof_prb++; + } + memcpy(&prb_dist->slot[1], &prb_dist->slot[0], sizeof(ra_prb_slot_t)); + break; + } return LIBLTE_SUCCESS; } diff --git a/lte/phy/lib/phch/test/pusch_encode_test_mex.c b/lte/phy/lib/phch/test/pusch_encode_test_mex.c index 5c468f188..7c5d2785e 100644 --- a/lte/phy/lib/phch/test/pusch_encode_test_mex.c +++ b/lte/phy/lib/phch/test/pusch_encode_test_mex.c @@ -38,7 +38,7 @@ #define CQI prhs[3] #define RI prhs[4] #define ACK prhs[5] -#define NOF_INPUTS 3 +#define NOF_INPUTS 6 void help() { @@ -49,41 +49,45 @@ void help() /* the gateway function */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { - int i; - lte_cell_t cell; - pusch_t pusch; - uint32_t sf_idx; - uint8_t *trblkin = NULL; - cf_t *sf_symbols = NULL; - ra_mcs_t mcs; - ra_prb_t prb_alloc; - harq_t harq_process; - uint32_t rv; - uint32_t rnti32; - uci_data_t uci_data; - bzero(&uci_data, sizeof(uci_data_t)); if (nrhs != NOF_INPUTS) { help(); return; } - + + lte_cell_t cell; + bzero(&cell, sizeof(lte_cell_t)); + cell.nof_ports = 1; if (mexutils_read_uint32_struct(UECFG, "NCellID", &cell.id)) { - mexErrMsgTxt("Field NCellID not found in pusch config\n"); + mexErrMsgTxt("Field NCellID not found in UE config\n"); return; } - if (mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx)) { - mexErrMsgTxt("Field NCellID not found in pusch config\n"); + if (mexutils_read_uint32_struct(UECFG, "NULRB", &cell.nof_prb)) { + mexErrMsgTxt("Field NULRB not found in UE config\n"); return; } - + pusch_t pusch; + if (pusch_init(&pusch, cell)) { + mexErrMsgTxt("Error initiating PUSCH\n"); + return; + } + uint32_t rnti32=0; if (mexutils_read_uint32_struct(UECFG, "RNTI", &rnti32)) { mexErrMsgTxt("Field RNTI not found in pusch config\n"); return; } + pusch_set_rnti(&pusch, (uint16_t) (rnti32 & 0xffff)); + - char *mod_str = mexutils_get_char_struct(PUSCHCFG, "Modulation"); + + uint32_t sf_idx=0; + if (mexutils_read_uint32_struct(UECFG, "NSubframe", &sf_idx)) { + mexErrMsgTxt("Field NSubframe not found in UE config\n"); + return; + } + ra_mcs_t mcs; + char *mod_str = mexutils_get_char_struct(PUSCHCFG, "Modulation"); if (!strcmp(mod_str, "QPSK")) { mcs.mod = LTE_QPSK; } else if (!strcmp(mod_str, "16QAM")) { @@ -105,13 +109,14 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } + ra_prb_t prb_alloc; // Only localized PRB supported prb_alloc.slot[0].nof_prb = mexutils_read_f(p, &prbset); - for (i=0;i 0) { + if (harq_setup_ul(&harq_process, mcs, rv, sf_idx, &prb_alloc)) { + mexErrMsgTxt("Error configuring HARQ process\n"); + return; + } + r = pusch_uci_encode(&pusch, &harq_process, trblkin, uci_data, sf_symbols); + if (r < 0) { + mexErrMsgTxt("Error encoding PUSCH\n"); + return; + } + } if (nlhs >= 1) { - mexutils_write_cf(sf_symbols, &plhs[0], harq_process.nof_re, 1); + mexutils_write_cf(sf_symbols, &plhs[0], nof_re, 1); + } + if (nlhs >= 2) { + mexutils_write_cf(pusch.pusch_z, &plhs[1], harq_process.nof_re, 1); } pusch_free(&pusch); free(trblkin); diff --git a/lte/phy/lib/phch/test/pusch_test.c b/lte/phy/lib/phch/test/pusch_test.c index 05aaf91ee..7d8e87763 100644 --- a/lte/phy/lib/phch/test/pusch_test.c +++ b/lte/phy/lib/phch/test/pusch_test.c @@ -112,9 +112,7 @@ void parse_args(int argc, char **argv) { int main(int argc, char **argv) { pusch_t pusch; uint8_t *data = NULL; - cf_t *ce; - uint32_t nof_re; - cf_t *sf_symbols; + cf_t *sf_symbols = NULL; int ret = -1; struct timeval t[3]; ra_mcs_t mcs; @@ -123,32 +121,13 @@ int main(int argc, char **argv) { parse_args(argc,argv); - nof_re = 2 * CPNORM_NSYMB * cell.nof_prb * RE_X_RB; - mcs.tbs = tbs; mcs.mod = modulation; - prb_alloc.slot[0].nof_prb = 1; + bzero(&prb_alloc, sizeof(ra_prb_t)); + prb_alloc.slot[0].nof_prb = 2; memcpy(&prb_alloc.slot[1], &prb_alloc.slot[0], sizeof(ra_prb_slot_t)); - /* init memory */ - ce = malloc(sizeof(cf_t) * nof_re); - if (!ce) { - perror("malloc"); - goto quit; - } - sf_symbols = calloc(sizeof(cf_t) , nof_re); - if (!sf_symbols) { - perror("malloc"); - goto quit; - } - - data = malloc(sizeof(uint8_t) * mcs.tbs); - if (!data) { - perror("malloc"); - goto quit; - } - if (pusch_init(&pusch, cell)) { fprintf(stderr, "Error creating PDSCH object\n"); goto quit; @@ -160,13 +139,6 @@ int main(int argc, char **argv) { goto quit; } - for (uint32_t i=0;ilen); for (i = 0; i < len; i++) { - if (data[i] == 'x') { + if (data[i] == 3) { data[i] = 1; - } else if (data[i] == 'y') { + } else if (data[i] == 2) { if (i > 1) { data[i] = data[i-1]; } diff --git a/matlab/tests/pusch_test.m b/matlab/tests/pusch_test.m new file mode 100644 index 000000000..1eb781c29 --- /dev/null +++ b/matlab/tests/pusch_test.m @@ -0,0 +1,66 @@ +clear +ueConfig=struct('NCellID',3,'NULRB',6,'NSubframe',0,'RNTI',1,'CyclicPrefixUL','Normal','NTxAnts',1); +puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',[0 2 4 5]','Modulation','QPSK','RV',0,'Shortened',0); + +addpath('../../debug/lte/phy/lib/phch/test') + + TBs=0:13:211; + cqilen=[0, 8, 17]; + mods={'QPSK','16QAM','64QAM'}; + rvs=0; + 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; + + puschConfig.Modulation = mods{m}; + puschConfig.RV = rvs(r); + 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 + + if (cqilen(c)>0 || TBs(i)>0) + [cw, info]=lteULSCH(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit,[]); + cw_mat=ltePUSCH(ueConfig,puschConfig,cw); + idx=ltePUSCHIndices(ueConfig,puschConfig); + subframe_mat = lteULResourceGrid(ueConfig); + subframe_mat(idx)=cw_mat; + [subframe_lib, cwlib]=liblte_pusch_encode(ueConfig,puschConfig,trblkin,ones(1,cqilen(c)),ri_bit,ack_bit); + err=mean(abs(subframe_mat(:)-subframe_lib)); + if (err > 10^-6) + disp(err) + error('Error!'); + end + end + end + end + end + end + end + end +end + +if (length(TBs) == 1) + %disp(info) + n=1:length(mat); + %plot(abs(double(mat)-double(lib))) + plot(n,real(lib(n)),n,real(mat(n))) +end diff --git a/matlab/tests/ulsch_test.m b/matlab/tests/ulsch_test.m index d59cbfd55..fec74586c 100644 --- a/matlab/tests/ulsch_test.m +++ b/matlab/tests/ulsch_test.m @@ -4,11 +4,12 @@ puschConfig=struct('NLayers',1,'OrthCover','Off','PRBSet',0,'Modulation','16QAM' addpath('../../debug/lte/phy/lib/phch/test') -TBs=0:13:222; -cqilen=[0, 8, 17]; -mods={'QPSK','16QAM','64QAM'}; -rvs=[0, 3]; -betas=0:3:11; + TBs=0:13:222; + cqilen=0;%[0, 8, 17]; + mods={'QPSK','16QAM','64QAM'}; + rvs=0;%[0, 3]; + betas=0:3:11; + for i=1:length(TBs) for m=1:length(mods)