From de1b25558f200bf82bb6248010e4bee0632ed24e Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Thu, 20 May 2021 13:43:49 +0200 Subject: [PATCH] Added PRN sequence apply bit with state --- lib/include/srsran/phy/common/sequence.h | 5 ++++- lib/src/phy/common/sequence.c | 24 ++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/include/srsran/phy/common/sequence.h b/lib/include/srsran/phy/common/sequence.h index cf9f5f12d..83cb35310 100644 --- a/lib/include/srsran/phy/common/sequence.h +++ b/lib/include/srsran/phy/common/sequence.h @@ -39,7 +39,10 @@ SRSRAN_API void srsran_sequence_state_gen_f(srsran_sequence_state_t* s, float va SRSRAN_API void srsran_sequence_state_apply_f(srsran_sequence_state_t* s, const float* in, float* out, uint32_t length); SRSRAN_API void -srsran_sequence_state_apply_bit(srsran_sequence_state_t* s, const uint8_t* in, uint8_t* out, uint32_t length); +srsran_sequence_state_apply_c(srsran_sequence_state_t* s, const int8_t* in, int8_t* out, uint32_t length); + +SRSRAN_API +void srsran_sequence_state_apply_bit(srsran_sequence_state_t* s, const uint8_t* in, uint8_t* out, uint32_t length); SRSRAN_API void srsran_sequence_state_advance(srsran_sequence_state_t* s, uint32_t length); diff --git a/lib/src/phy/common/sequence.c b/lib/src/phy/common/sequence.c index 95e0c1089..b9a86552d 100644 --- a/lib/src/phy/common/sequence.c +++ b/lib/src/phy/common/sequence.c @@ -551,16 +551,13 @@ void srsran_sequence_apply_s(const int16_t* in, int16_t* out, uint32_t length, u } } -void srsran_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uint32_t seed) +void srsran_sequence_state_apply_c(srsran_sequence_state_t* s, const int8_t* in, int8_t* out, uint32_t length) { - uint32_t x1 = sequence_x1_init; // X1 initial state is fix - uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state - uint32_t i = 0; if (length >= SEQUENCE_PAR_BITS) { for (; i < length - (SEQUENCE_PAR_BITS - 1); i += SEQUENCE_PAR_BITS) { - uint32_t c = (uint32_t)(x1 ^ x2); + uint32_t c = (uint32_t)(s->x1 ^ s->x2); uint32_t j = 0; #ifdef LV_HAVE_SSE @@ -597,20 +594,27 @@ void srsran_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uin } // Step sequences - x1 = sequence_gen_LTE_pr_memless_step_par_x1(x1); - x2 = sequence_gen_LTE_pr_memless_step_par_x2(x2); + s->x1 = sequence_gen_LTE_pr_memless_step_par_x1(s->x1); + s->x2 = sequence_gen_LTE_pr_memless_step_par_x2(s->x2); } } for (; i < length; i++) { - out[i] = in[i] * (((x1 ^ x2) & 1U) ? -1 : +1); + out[i] = in[i] * (((s->x1 ^ s->x2) & 1U) ? -1 : +1); // Step sequences - x1 = sequence_gen_LTE_pr_memless_step_x1(x1); - x2 = sequence_gen_LTE_pr_memless_step_x2(x2); + s->x1 = sequence_gen_LTE_pr_memless_step_x1(s->x1); + s->x2 = sequence_gen_LTE_pr_memless_step_x2(s->x2); } } +void srsran_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uint32_t seed) +{ + srsran_sequence_state_t sequence_state; + srsran_sequence_state_init(&sequence_state, seed); + srsran_sequence_state_apply_c(&sequence_state, in, out, length); +} + void srsran_sequence_state_apply_bit(srsran_sequence_state_t* s, const uint8_t* in, uint8_t* out, uint32_t length) { uint32_t i = 0;