mirror of
https://github.com/aicodix/modem.git
synced 2026-04-27 22:35:41 +00:00
replaced reserved tones with pilot tones
This commit is contained in:
parent
4838e75415
commit
04beed4a4c
3 changed files with 16 additions and 61 deletions
14
common.hh
14
common.hh
|
|
@ -18,18 +18,16 @@ struct Common
|
|||
static const int data_max = 4096;
|
||||
static const int mls0_poly = 0x331;
|
||||
static const int mls0_seed = 214;
|
||||
static const int mls1_poly = 0x25;
|
||||
static const int mls1_poly = 0x43;
|
||||
static const int data_tones = 256;
|
||||
static const int pilot_tones = 32;
|
||||
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 pilot_tones = 64;
|
||||
static const int tone_count = data_tones + pilot_tones;
|
||||
static const int block_length = 5;
|
||||
static const int block_skew = 3;
|
||||
static const int first_pilot = 4;
|
||||
static const int first_reserved = 9;
|
||||
CODE::CRC<uint32_t> crc0;
|
||||
CODE::HadamardEncoder<6> hadamard_encoder;
|
||||
int8_t meta[32];
|
||||
CODE::HadamardEncoder<7> hadamard_encoder;
|
||||
int8_t meta[64];
|
||||
uint8_t data[data_max];
|
||||
const uint32_t *frozen_bits;
|
||||
int mod_bits;
|
||||
|
|
|
|||
12
decode.cc
12
decode.cc
|
|
@ -49,7 +49,7 @@ struct Decoder : Common
|
|||
DSP::BipBuffer<cmplx, buffer_len> input_hist;
|
||||
DSP::TheilSenEstimator<value, tone_count> tse;
|
||||
SchmidlCox<value, cmplx, search_pos, symbol_len, guard_len> correlator;
|
||||
CODE::HadamardDecoder<6> hadamard_decoder;
|
||||
CODE::HadamardDecoder<7> hadamard_decoder;
|
||||
CODE::PolarListDecoder<mesg_type, code_max> polar_decoder;
|
||||
mesg_type mesg[bits_max];
|
||||
code_type code[bits_max], perm[bits_max];
|
||||
|
|
@ -251,7 +251,6 @@ struct Decoder : Common
|
|||
std::cerr << "Es/N0 (dB):";
|
||||
for (int j = 0, k = 0; j < symbol_count; ++j) {
|
||||
pilot_off = (block_skew * j + first_pilot) % block_length;
|
||||
reserved_off = (block_skew * j + first_reserved) % block_length;
|
||||
if (j) {
|
||||
for (int i = 0; i < extended_len; ++i)
|
||||
correlator(buf = next_sample());
|
||||
|
|
@ -294,20 +293,17 @@ struct Decoder : Common
|
|||
chan[i] *= DSP::polar<value>(1, tse(i+tone_off));
|
||||
if (differential) {
|
||||
for (int i = 0; i < tone_count; ++i)
|
||||
if (i % block_length != reserved_off)
|
||||
chan[i] = fdom[bin(i+tone_off)];
|
||||
chan[i] = fdom[bin(i+tone_off)];
|
||||
} else {
|
||||
for (int i = pilot_off; i < tone_count; i += block_length)
|
||||
chan[i] = DSP::lerp(chan[i], tone[i], value(0.5));
|
||||
}
|
||||
CODE::MLS seq(0x163, meta_data);
|
||||
for (int i = 0; i < tone_count; ++i)
|
||||
if (i % block_length != pilot_off && i % block_length != reserved_off)
|
||||
if (i % block_length != pilot_off)
|
||||
demod[i] *= nrz(seq());
|
||||
value sp = 0, np = 0;
|
||||
for (int i = 0, l = k; i < tone_count; ++i) {
|
||||
if (i % block_length == reserved_off)
|
||||
continue;
|
||||
cmplx hard(1, 0);
|
||||
if (i % block_length != pilot_off) {
|
||||
int bits = mod_bits;
|
||||
|
|
@ -329,8 +325,6 @@ struct Decoder : Common
|
|||
for (int i = 0; i < tone_count; ++i) {
|
||||
if (i % block_length == pilot_off)
|
||||
continue;
|
||||
if (i % block_length == reserved_off)
|
||||
continue;
|
||||
int bits = mod_bits;
|
||||
if (oper_mode >= 7 && oper_mode <= 9 && k % 32 == 30)
|
||||
bits = 2;
|
||||
|
|
|
|||
51
encode.cc
51
encode.cc
|
|
@ -48,7 +48,7 @@ struct Encoder : public Common
|
|||
{
|
||||
return 1 - 2 * bit;
|
||||
}
|
||||
void clipping_and_filtering(value scale, bool limit)
|
||||
void clipping_and_filtering(value scale)
|
||||
{
|
||||
for (int i = 0; i < symbol_len; ++i) {
|
||||
value pwr = norm(tdom[i]);
|
||||
|
|
@ -58,39 +58,17 @@ struct Encoder : public Common
|
|||
fwd(fdom, tdom);
|
||||
for (int i = 0; i < symbol_len; ++i) {
|
||||
int j = bin(i + tone_off);
|
||||
if (i >= tone_count) {
|
||||
if (i >= tone_count)
|
||||
fdom[j] = 0;
|
||||
} else if (i % block_length == pilot_off) {
|
||||
else if (i % block_length == pilot_off)
|
||||
fdom[j] = temp[i];
|
||||
} else if (i % block_length == reserved_off) {
|
||||
fdom[j] = 0;
|
||||
} else {
|
||||
else
|
||||
fdom[j] *= 1 / (scale * symbol_len);
|
||||
cmplx err = fdom[j] - temp[i];
|
||||
value mag = abs(err);
|
||||
value lim = 0.5 * mod_distance();
|
||||
if (limit && mag > lim)
|
||||
fdom[j] -= ((mag - lim) / mag) * err;
|
||||
}
|
||||
}
|
||||
bwd(tdom, fdom);
|
||||
for (int i = 0; i < symbol_len; ++i)
|
||||
tdom[i] *= scale;
|
||||
}
|
||||
void tone_reservation()
|
||||
{
|
||||
for (int n = 0; n < 10; ++n) {
|
||||
int peak = 0;
|
||||
for (int i = 1; i < symbol_len; ++i)
|
||||
if (norm(tdom[peak]) < norm(tdom[i]))
|
||||
peak = i;
|
||||
cmplx orig = tdom[peak];
|
||||
if (norm(orig) <= value(1))
|
||||
break;
|
||||
for (int i = 0; i < symbol_len; ++i)
|
||||
tdom[i] -= orig * kern[bin(i-peak)];
|
||||
}
|
||||
}
|
||||
void symbol(int symbol_number)
|
||||
{
|
||||
for (int i = 0; differential && symbol_number > 0 && i < tone_count; ++i)
|
||||
|
|
@ -105,7 +83,7 @@ struct Encoder : public Common
|
|||
for (int i = 0, m = 0; i < tone_count; ++i)
|
||||
if (i % block_length == pilot_off)
|
||||
temp[i] *= meta[m++];
|
||||
else if (i % block_length != reserved_off)
|
||||
else
|
||||
temp[i] *= nrz(seq());
|
||||
}
|
||||
for (int i = 0; i < symbol_len; ++i)
|
||||
|
|
@ -117,10 +95,8 @@ struct Encoder : public Common
|
|||
for (int i = 0; i < symbol_len; ++i)
|
||||
tdom[i] *= scale;
|
||||
bool papr_reduction = symbol_number >= 0;
|
||||
if (papr_reduction) {
|
||||
clipping_and_filtering(scale, true);
|
||||
tone_reservation();
|
||||
}
|
||||
if (papr_reduction)
|
||||
clipping_and_filtering(scale);
|
||||
auto clamp = [](value v){ return v < value(-1) ? value(-1) : v > value(1) ? value(1) : v; };
|
||||
for (int i = 0; i < symbol_len; ++i)
|
||||
tdom[i] = cmplx(clamp(tdom[i].real()), clamp(tdom[i].imag()));
|
||||
|
|
@ -243,15 +219,6 @@ struct Encoder : public Common
|
|||
dest[i] = src[seq()];
|
||||
}
|
||||
}
|
||||
void tone_reservation_kernel()
|
||||
{
|
||||
value mag(0.001);
|
||||
for (int i = 0; i < symbol_len; ++i)
|
||||
fdom[i] = 0;
|
||||
for (int i = 0; i < reserved_tones; ++i)
|
||||
fdom[bin(i*block_length+tone_off+reserved_off)] = mag;
|
||||
bwd(kern, fdom);
|
||||
}
|
||||
void guard_interval_weights()
|
||||
{
|
||||
for (int i = 0; i < guard_len / 4; ++i)
|
||||
|
|
@ -298,12 +265,9 @@ struct Encoder : public Common
|
|||
std::cerr << "PAPR (dB):";
|
||||
for (int j = 0, k = 0; j < symbol_count; ++j) {
|
||||
pilot_off = (block_skew * j + first_pilot) % block_length;
|
||||
reserved_off = (block_skew * j + first_reserved) % block_length;
|
||||
for (int i = 0; i < tone_count; ++i) {
|
||||
if (i % block_length == pilot_off) {
|
||||
tone[i] = nrz(seq1());
|
||||
} else if (i % block_length == reserved_off) {
|
||||
tone[i] = 0;
|
||||
} else {
|
||||
int bits = mod_bits;
|
||||
if (oper_mode >= 7 && oper_mode <= 9 && k % 32 == 30)
|
||||
|
|
@ -314,7 +278,6 @@ struct Encoder : public Common
|
|||
k += bits;
|
||||
}
|
||||
}
|
||||
tone_reservation_kernel();
|
||||
symbol(j);
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue