From 838155c0630e2020ed42ef399db8057ff11d0056 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Tue, 1 Jul 2025 08:26:28 +0200 Subject: [PATCH] skew pilot and reserved tones --- decode.cc | 18 +++++++++++------- encode.cc | 7 +++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/decode.cc b/decode.cc index faec2c6..86367e2 100644 --- a/decode.cc +++ b/decode.cc @@ -59,6 +59,7 @@ struct Decoder static const int reserved_tones = 32; static const int data_tones = 256; static const int block_length = 10; + static const int block_skew = 3; static const int pilot_offset = 4; static const int reserved_offset = 9; static const int tone_count = data_tones + pilot_tones + reserved_tones; @@ -324,13 +325,14 @@ struct Decoder seq1.reset(); hadamardenc(mode, oper_mode); } + int poff = (block_skew * j + pilot_offset) % block_length; for (int i = 0; i < pilot_tones; ++i) - tone[block_length*i+pilot_offset] *= nrz(seq1()) * mode[i]; + tone[block_length*i+poff] *= nrz(seq1()) * mode[i]; for (int i = 0; i < tone_count; ++i) demod[tone_count*j+i] = demod_or_erase(tone[i], chan[i]); for (int i = 0; i < pilot_tones; ++i) { - index[i] = tone_off + block_length * i + pilot_offset; - phase[i] = arg(demod[tone_count*j+block_length*i+pilot_offset]); + index[i] = tone_off + block_length * i + poff; + phase[i] = arg(demod[tone_count*j+block_length*i+poff]); } tse.compute(index, phase, pilot_tones); //std::cerr << "Theil-Sen slope = " << tse.slope() << std::endl; @@ -338,7 +340,7 @@ struct Decoder for (int i = 0; i < tone_count; ++i) demod[tone_count*j+i] *= DSP::polar(1, -tse(i+tone_off)); for (int i = 0; i < tone_count; ++i) - if (i % block_length == pilot_offset) + if (i % block_length == poff) chan[i] = tone[i]; else chan[i] *= DSP::polar(1, tse(i+tone_off)); @@ -348,9 +350,11 @@ struct Decoder std::cerr << "Es/N0 (dB):"; value sp = 0, np = 0; for (int j = 0, k = 0; j < symbol_count; ++j) { + int poff = (block_skew * j + pilot_offset) % block_length; + int roff = (block_skew * j + reserved_offset) % block_length; for (int i = 0; i < pilot_tones; ++i) { cmplx hard(1, 0); - cmplx error = demod[tone_count*j+block_length*i+pilot_offset] - hard; + cmplx error = demod[tone_count*j+block_length*i+poff] - hard; sp += norm(hard); np += norm(error); } @@ -361,9 +365,9 @@ struct Decoder if (std::is_same::value && precision > 32) precision = 32; for (int i = 0; i < tone_count; ++i) { - if (i % block_length == pilot_offset) + if (i % block_length == poff) continue; - if (i % block_length == reserved_offset) + if (i % block_length == roff) continue; mod_soft(perm+k, demod[tone_count*j+i], precision); k += mod_bits; diff --git a/encode.cc b/encode.cc index af3b27c..e69ffa0 100644 --- a/encode.cc +++ b/encode.cc @@ -40,6 +40,7 @@ struct Encoder static const int reserved_tones = 32; static const int tone_count = data_tones + pilot_tones + reserved_tones; static const int block_length = 10; + static const int block_skew = 3; static const int pilot_offset = 4; static const int reserved_offset = 9; DSP::WritePCM *pcm; @@ -354,10 +355,12 @@ struct Encoder shuffle(perm, code); CODE::MLS seq1(mls1_poly); for (int j = 0, k = 0; j < symbol_count; ++j) { + int poff = (block_skew * j + pilot_offset) % block_length; + int roff = (block_skew * j + reserved_offset) % block_length; for (int i = 0, m = 0; i < tone_count; ++i) { - if (i % block_length == pilot_offset) { + if (i % block_length == poff) { tone[i] = nrz(seq1()) * mode[m++]; - } else if (i % block_length == reserved_offset) { + } else if (i % block_length == roff) { tone[i] = 0; } else { tone[i] = mod_map(perm+k);