From 2e7a357226a6ead50c5a472635816feccbef3292 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 8 Jan 2020 14:05:38 +0100 Subject: [PATCH] expose UL-SCH interleaver to use in Sidelink --- lib/include/srslte/phy/phch/sch.h | 17 ++++++++++++++++- lib/src/phy/phch/sch.c | 21 ++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/include/srslte/phy/phch/sch.h b/lib/include/srslte/phy/phch/sch.h index 4888e41ab..6f1b46d3c 100644 --- a/lib/include/srslte/phy/phch/sch.h +++ b/lib/include/srslte/phy/phch/sch.h @@ -122,4 +122,19 @@ SRSLTE_API uint32_t srslte_sch_find_Ioffset_cqi(float beta); SRSLTE_API uint32_t srslte_sch_find_Ioffset_ri(float beta); -#endif // SRSLTE_SCH_H +///< Sidelink uses PUSCH Interleaver in all channels +SRSLTE_API void srslte_sl_ulsch_interleave(uint8_t* g_bits, + uint32_t Qm, + uint32_t H_prime_total, + uint32_t N_pusch_symbs, + uint8_t* q_bits); + +///< Sidelink uses PUSCH Deinterleaver in all channels +SRSLTE_API void srslte_sl_ulsch_deinterleave(int16_t* q_bits, + uint32_t Qm, + uint32_t H_prime_total, + uint32_t N_pusch_symbs, + int16_t* g_bits, + uint32_t* inteleaver_lut); + +#endif // SRSLTE_SCH_H \ No newline at end of file diff --git a/lib/src/phy/phch/sch.c b/lib/src/phy/phch/sch.c index 2f91f2bba..5e5ff73a1 100644 --- a/lib/src/phy/phch/sch.c +++ b/lib/src/phy/phch/sch.c @@ -620,7 +620,7 @@ static void ulsch_interleave_gen(uint32_t H_prime_total, for (uint32_t j = 0; j < rows; j++) { for (uint32_t i = 0; i < cols; i++) { for (uint32_t k = 0; k < Qm; k++) { - if (ri_present[j * Qm + i * rows * Qm + k]) { + if (ri_present && ri_present[j * Qm + i * rows * Qm + k]) { interleaver_lut[j * Qm + i * rows * Qm + k] = 0; } else { interleaver_lut[j * Qm + i * rows * Qm + k] = idx; @@ -1257,3 +1257,22 @@ int srslte_ulsch_encode(srslte_sch_t* q, return nof_ri_ack_bits; } + +void srslte_sl_ulsch_interleave(uint8_t* g_bits, + uint32_t Qm, + uint32_t H_prime_total, + uint32_t N_pusch_symbs, + uint8_t* q_bits) +{ + ulsch_interleave(g_bits, Qm, H_prime_total, N_pusch_symbs, q_bits, NULL, 0, false); +} + +void srslte_sl_ulsch_deinterleave(int16_t* q_bits, + uint32_t Qm, + uint32_t H_prime_total, + uint32_t N_pusch_symbs, + int16_t* g_bits, + uint32_t* inteleaver_lut) +{ + ulsch_deinterleave(q_bits, Qm, H_prime_total, N_pusch_symbs, g_bits, NULL, 0, NULL, inteleaver_lut); +} \ No newline at end of file