From a6c75950e619982e47d69baa66a099e9a74aaeab Mon Sep 17 00:00:00 2001 From: Wojciech Kaczmarski Date: Tue, 9 Jan 2024 11:05:06 +0100 Subject: [PATCH] added new functions - soft_bit_NOT() - reorder_soft_bits() --- SP5WWP/include/m17/m17.h | 2 ++ SP5WWP/lib/math/math.c | 11 +++++++++++ SP5WWP/lib/phy/interleave.c | 14 +++++++++++++- SP5WWP/m17-decoder/m17-decoder-sym.c | 9 +++------ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/SP5WWP/include/m17/m17.h b/SP5WWP/include/m17/m17.h index 1988c1b..559064e 100644 --- a/SP5WWP/include/m17/m17.h +++ b/SP5WWP/include/m17/m17.h @@ -84,6 +84,7 @@ void encode_LICH(uint8_t outp[12], const uint8_t inp[6]); extern const uint16_t intrl_seq[SYM_PER_PLD*2]; void reorder_bits(uint8_t outp[SYM_PER_PLD*2], const uint8_t inp[SYM_PER_PLD*2]); +void reorder_soft_bits(uint16_t outp[SYM_PER_PLD*2], const uint16_t inp[SYM_PER_PLD*2]); // M17 C library - lib/math/math.c uint16_t q_abs_diff(const uint16_t v1, const uint16_t v2); @@ -93,6 +94,7 @@ uint16_t soft_to_int(const uint16_t* in, const uint8_t len); uint16_t div16(const uint16_t a, const uint16_t b); uint16_t mul16(const uint16_t a, const uint16_t b); uint16_t soft_bit_XOR(const uint16_t a, const uint16_t b); +uint16_t soft_bit_NOT(const uint16_t a); void soft_XOR(uint16_t* out, const uint16_t* a, const uint16_t* b, const uint8_t len); // M17 C library - lib/phy/randomize.c diff --git a/SP5WWP/lib/math/math.c b/SP5WWP/lib/math/math.c index b78db64..2e868ef 100644 --- a/SP5WWP/lib/math/math.c +++ b/SP5WWP/lib/math/math.c @@ -153,6 +153,17 @@ uint16_t soft_bit_XOR(const uint16_t a, const uint16_t b) return add16(mul16(a, sub16(0xFFFF, b)), mul16(b, sub16(0xFFFF, a))); } +/** + * @brief Soft logic NOT. + * + * @param a Input A. + * @return uint16_t Output = not A. + */ +uint16_t soft_bit_NOT(const uint16_t a) +{ + return 0xFFFFU-a; +} + /** * @brief XOR for vectors of soft-valued logic. * Max length is 255. diff --git a/SP5WWP/lib/phy/interleave.c b/SP5WWP/lib/phy/interleave.c index f0a8e26..14743cd 100644 --- a/SP5WWP/lib/phy/interleave.c +++ b/SP5WWP/lib/phy/interleave.c @@ -36,7 +36,7 @@ const uint16_t intrl_seq[SYM_PER_PLD*2]= }; /** - * @brief Reorder (interleave) unpacked payload bits. + * @brief Reorder (interleave) 368 unpacked payload bits. * * @param outp Reordered, unpacked type-4 bits. * @param inp Input unpacked type-2/3 bits. @@ -46,3 +46,15 @@ void reorder_bits(uint8_t outp[SYM_PER_PLD*2], const uint8_t inp[SYM_PER_PLD*2]) for(uint16_t i=0; i>(7-(i%8)))&1) //soft XOR. flip soft bit if "1" - soft_bit[i]=0xFFFF-soft_bit[i]; + if((rand_seq[i/8]>>(7-(i%8)))&1) //soft NOT. flip soft bit if "1" + soft_bit[i]=soft_bit_NOT(soft_bit[i]); } //deinterleave - for(uint16_t i=0; i