From 67355dbdb350aa4be6903ea8f3456ac70a4d1a9e Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sun, 15 Feb 2026 09:08:17 +0100 Subject: [PATCH] init conv state with last 6 bits --- pac_encoder.hh | 9 ++++++++- pac_list_decoder.hh | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pac_encoder.hh b/pac_encoder.hh index 8e141c5..98f73eb 100644 --- a/pac_encoder.hh +++ b/pac_encoder.hh @@ -22,7 +22,7 @@ class PACEncoder bool b4 = (*state >> 4) & 1; bool b6 = (*state >> 6) & 1; bool output = input ^ b1 ^ b3 ^ b4 ^ b6; - *state = ((*state & 62) << 1) | (input ? 2 : 0) | (output ? 1 : 0); + *state = (*state & 8064) | ((*state & 62) << 1) | (input ? 2 : 0) | (output ? 1 : 0); return output; } public: @@ -31,6 +31,13 @@ public: int length = 1 << level; int state = 0; int frozen = length - mesg_bits; + for (int i = 0, j = 0; i < length; i += 2) { + TYPE msg0 = rank_map[i] < frozen ? PH::one() : message[j++]; + TYPE msg1 = rank_map[i+1] < frozen ? PH::one() : message[j++]; + conv(&state, msg0 < 0); + conv(&state, msg1 < 0); + } + state |= (state & 126) << 7; for (int i = 0; i < length; i += 2) { TYPE msg0 = rank_map[i] < frozen ? PH::one() : *message++; TYPE msg1 = rank_map[i+1] < frozen ? PH::one() : *message++; diff --git a/pac_list_decoder.hh b/pac_list_decoder.hh index e1f0361..fcaa3c1 100644 --- a/pac_list_decoder.hh +++ b/pac_list_decoder.hh @@ -46,7 +46,7 @@ struct PACListTree bool b4 = (*state >> 4) & 1; bool b6 = (*state >> 6) & 1; bool output = input ^ b1 ^ b3 ^ b4 ^ b6; - *state = ((*state & 62) << 1) | (input ? 2 : 0) | (output ? 1 : 0); + *state = (*state & 8064) | ((*state & 62) << 1) | (input ? 2 : 0) | (output ? 1 : 0); return output; } static MAP rate0(PATH *metric, int *state, TYPE *hard, TYPE *soft) @@ -119,6 +119,7 @@ template class PACListDecoder { static_assert(MAX_M >= 5 && MAX_M <= 8); + static_assert(TYPE::SIZE == 64); typedef PolarHelper PH; typedef typename TYPE::value_type VALUE; typedef typename PH::PATH PATH; @@ -133,15 +134,14 @@ public: assert(level <= MAX_M); PATH metric[TYPE::SIZE]; int count = 0; - metric[0] = 0; - for (int k = 1; k < TYPE::SIZE; ++k) - metric[k] = 1000000; + for (int k = 0; k < TYPE::SIZE; ++k) + metric[k] = 0; int length = 1 << level; for (int i = 0; i < length; ++i) soft[length+i] = vdup(codeword[i]); int state[TYPE::SIZE]; for (int i = 0; i < TYPE::SIZE; ++i) - state[i] = 0; + state[i] = (i << 7) | (i << 1); int frozen = length - mesg_bits; switch (level) {