diff --git a/srslte/include/srslte/phch/sch.h b/srslte/include/srslte/phch/sch.h index 9023fa760..41ece6b26 100644 --- a/srslte/include/srslte/phch/sch.h +++ b/srslte/include/srslte/phch/sch.h @@ -118,9 +118,10 @@ SRSLTE_API int srslte_ulsch_uci_encode(srslte_sch_t *q, uint8_t *q_bits); SRSLTE_API int srslte_ulsch_decode(srslte_sch_t *q, - srslte_pusch_cfg_t *cfg, + srslte_pusch_cfg_t *cfg, srslte_softbuffer_rx_t *softbuffer, - int16_t *e_bits, + int16_t *q_bits, + int16_t *g_bits, uint8_t *data); SRSLTE_API float srslte_sch_beta_cqi(uint32_t I_cqi); diff --git a/srslte/lib/phch/pusch.c b/srslte/lib/phch/pusch.c index a101026d3..448f99898 100644 --- a/srslte/lib/phch/pusch.c +++ b/srslte/lib/phch/pusch.c @@ -463,7 +463,7 @@ int srslte_pusch_uci_encode_rnti(srslte_pusch_t *q, srslte_pusch_cfg_t *cfg, srs uint8_t tx_bits[10000]; srslte_bit_unpack_vector(q->q, tx_bits, cfg->nbits.nof_bits); srslte_vec_save_file("tx_bits", tx_bits, sizeof(uint8_t)*cfg->nbits.nof_bits); - + if (rnti != q->rnti || !q->rnti_is_set) { srslte_sequence_t seq; if (srslte_sequence_pusch(&seq, rnti, 2 * cfg->sf_idx, q->cell.id, cfg->nbits.nof_bits)) { @@ -557,16 +557,16 @@ int srslte_pusch_decode(srslte_pusch_t *q, srslte_vec_save_file("rx_symbols", q->d, sizeof(cf_t)*cfg->nbits.nof_re); // Soft demodulation - srslte_demod_soft_demodulate(cfg->grant.mcs.mod, q->d, q->q, cfg->nbits.nof_re); + srslte_demod_soft_demodulate_s(cfg->grant.mcs.mod, q->d, q->q, cfg->nbits.nof_re); - srslte_vec_save_file("rx_bits_scram", q->q, sizeof(float)*cfg->nbits.nof_bits); + srslte_vec_save_file("rx_bits_scram", q->q, sizeof(int16_t)*cfg->nbits.nof_bits); // Descrambling - srslte_scrambling_f_offset(&q->seq[cfg->sf_idx], q->q, 0, cfg->nbits.nof_bits); + srslte_scrambling_s_offset(&q->seq[cfg->sf_idx], q->q, 0, cfg->nbits.nof_bits); - srslte_vec_save_file("rx_bits", q->q, sizeof(float)*cfg->nbits.nof_bits); + srslte_vec_save_file("rx_bits", q->q, sizeof(int16_t)*cfg->nbits.nof_bits); - return srslte_ulsch_decode(&q->dl_sch, cfg, softbuffer, q->q, data); + return srslte_ulsch_decode(&q->dl_sch, cfg, softbuffer, q->q, q->g, data); } else { fprintf(stderr, "Must call srslte_pusch_set_rnti() before calling srslte_pusch_decode()\n"); return SRSLTE_ERROR; diff --git a/srslte/lib/phch/sch.c b/srslte/lib/phch/sch.c index 88af978d7..8e2518531 100644 --- a/srslte/lib/phch/sch.c +++ b/srslte/lib/phch/sch.c @@ -498,114 +498,90 @@ int srslte_dlsch_encode(srslte_sch_t *q, srslte_pdsch_cfg_t *cfg, srslte_softbuf data, e_bits); } -/* UL-SCH channel interleaver according to 5.2.2.8 of 36.212 */ -void ulsch_interleave(uint8_t *g_bits, uint32_t Qm, uint32_t H_prime_total, - uint32_t N_pusch_symbs, uint8_t *q_bits, srslte_uci_bit_t *ri_bits, uint32_t nof_ri_bits, - uint16_t *interleaver_buffer, uint8_t *temp_buffer, uint32_t buffer_sz) +/* Compute the interleaving function on-the-fly, because it depends on number of RI bits + * Profiling show that the computation of this matrix is neglegible. + */ +static void ulsch_interleave_gen(uint32_t H_prime_total, uint32_t N_pusch_symbs, uint32_t Qm, + uint8_t *ri_present, uint16_t *interleaver_lut) { - uint32_t rows = H_prime_total/N_pusch_symbs; uint32_t cols = N_pusch_symbs; - - // Prepare ri_bits for fast search using temp_buffer - if (nof_ri_bits > 0) { - for (uint32_t i=0;i 0) { - for (uint32_t i=0;i 0) { + for (uint32_t i=0;i 0) { + for (uint32_t i=0;inbits.nof_symb, q_bits, q->ack_ri_bits, Q_prime_ri*Qm, - q->ul_interleaver, q->temp_g_bits, SRSLTE_MAX_PRB*12*12*12); + uint32_t Q_prime_ri = 0; + + uint32_t nb_q = cfg->nbits.nof_bits; + uint32_t Qm = cfg->grant.Qm; + // Interleave UL-SCH (and RI and CQI) + ulsch_deinterleave(q_bits, Qm, nb_q/Qm, cfg->nbits.nof_symb, g_bits, q->ack_ri_bits, Q_prime_ri*Qm, + q->temp_g_bits, q->ul_interleaver); - srslte_vec_fprint_f(stdout, q->temp_g_bits, nb_q); + printf("g_bits=["); + for (int i=0;i0); + } + printf("];\n"); - decode_tb(q, softbuffer, &cfg->cb_segm, + return decode_tb(q, softbuffer, &cfg->cb_segm, cfg->grant.Qm, cfg->rv, cfg->nbits.nof_bits, - e_bits, data); + g_bits, data); } int srslte_ulsch_encode(srslte_sch_t *q, srslte_pusch_cfg_t *cfg, srslte_softbuffer_tx_t *softbuffer, @@ -675,11 +651,12 @@ int srslte_ulsch_uci_encode(srslte_sch_t *q, uint8_t kk[10000]; srslte_bit_unpack_vector(g_bits, kk, nb_q); srslte_vec_save_file("g_bits_tx", kk, nb_q); + printf("g_bits_tx="); srslte_vec_fprint_b(stdout, kk, nb_q); // Interleave UL-SCH (and RI and CQI) ulsch_interleave(g_bits, Qm, nb_q/Qm, cfg->nbits.nof_symb, q_bits, q->ack_ri_bits, Q_prime_ri*Qm, - q->ul_interleaver, q->temp_g_bits, SRSLTE_MAX_PRB*12*12*12); + q->temp_g_bits, q->ul_interleaver); // Encode (and interleave) ACK if (uci_data.uci_ack_len > 0) {