align parity bits accordingly

if we want to use a crc aid at the end, we should move the start of the
first parity bit as far as possible to the front, otherwise we want the
last bit to be a parity bit
This commit is contained in:
Ahmet Inan 2024-01-21 11:05:31 +01:00
commit f3d3afbe01
2 changed files with 9 additions and 6 deletions

View file

@ -20,10 +20,10 @@ class PolarParityEncoder
return (bits[idx/32] >> (idx%32)) & 1; return (bits[idx/32] >> (idx%32)) & 1;
} }
public: public:
void operator()(TYPE *codeword, const TYPE *message, const uint32_t *frozen, int level, int stride) void operator()(TYPE *codeword, const TYPE *message, const uint32_t *frozen, int level, int stride, int first)
{ {
int length = 1 << level; int length = 1 << level;
int count = stride; int count = first;
TYPE parity = PH::one(); TYPE parity = PH::one();
for (int i = 0; i < length; i += 2) { for (int i = 0; i < length; i += 2) {
TYPE msg0, msg1; TYPE msg0, msg1;
@ -345,7 +345,7 @@ class PolarParityDecoder
TYPE hard[MAX_N]; TYPE hard[MAX_N];
MAP maps[MAX_N]; MAP maps[MAX_N];
public: public:
void operator()(PATH *metric, TYPE *message, const VALUE *codeword, const uint32_t *frozen, int level, int stride) void operator()(PATH *metric, TYPE *message, const VALUE *codeword, const uint32_t *frozen, int level, int stride, int first)
{ {
assert(level <= MAX_M); assert(level <= MAX_M);
int index = 0; int index = 0;
@ -356,7 +356,7 @@ public:
for (int i = 0; i < length; ++i) for (int i = 0; i < length; ++i)
soft[length+i] = vdup<TYPE>(codeword[i]); soft[length+i] = vdup<TYPE>(codeword[i]);
TYPE parity = PH::one(); TYPE parity = PH::one();
int count = stride; int count = first;
switch (level) { switch (level) {
case 5: PolarParityTree<TYPE, 5>::decode(metric, message, maps, &index, hard, soft, *frozen, &parity, &count, stride); break; case 5: PolarParityTree<TYPE, 5>::decode(metric, message, maps, &index, hard, soft, *frozen, &parity, &count, stride); break;

View file

@ -84,6 +84,9 @@ int main()
for (int i = 0; i < N - K; ++i) for (int i = 0; i < N - K; ++i)
frozen[reliability_sequence[i]/32] |= 1 << (reliability_sequence[i]%32); frozen[reliability_sequence[i]/32] |= 1 << (reliability_sequence[i]%32);
int P = K / (S + 1); int P = K / (S + 1);
int F = K % (S + 1);
if (!crc_aided)
F += S;
if (par_aided) if (par_aided)
K -= P; K -= P;
std::cerr << "Polar(" << N << ", " << K << ")" << std::endl; std::cerr << "Polar(" << N << ", " << K << ")" << std::endl;
@ -142,7 +145,7 @@ int main()
assert(codeword[i] == message[j++]); assert(codeword[i] == message[j++]);
} else if (par_aided) { } else if (par_aided) {
CODE::PolarParityEncoder<code_type> encode; CODE::PolarParityEncoder<code_type> encode;
encode(codeword, message, frozen, M, S); encode(codeword, message, frozen, M, S, F);
} else { } else {
CODE::PolarEncoder<code_type> encode; CODE::PolarEncoder<code_type> encode;
encode(codeword, message, frozen, M); encode(codeword, message, frozen, M);
@ -169,7 +172,7 @@ int main()
auto start = std::chrono::system_clock::now(); auto start = std::chrono::system_clock::now();
if (par_aided) if (par_aided)
(*par_dec)(metric, decoded, codeword, frozen, M, S); (*par_dec)(metric, decoded, codeword, frozen, M, S, F);
else else
(*decode)(metric, decoded, codeword, frozen, M); (*decode)(metric, decoded, codeword, frozen, M);
auto end = std::chrono::system_clock::now(); auto end = std::chrono::system_clock::now();