use 16 bit LLRs

This commit is contained in:
Ahmet Inan 2025-07-01 22:53:14 +02:00
commit b71926062d
3 changed files with 16 additions and 9 deletions

View file

@ -34,12 +34,8 @@ namespace DSP { using std::abs; using std::min; using std::cos; using std::sin;
template <typename value, typename cmplx, int rate>
struct Decoder
{
typedef int8_t code_type;
#ifdef __AVX2__
typedef SIMD<code_type, 32 / sizeof(code_type)> mesg_type;
#else
typedef SIMD<code_type, 16 / sizeof(code_type)> mesg_type;
#endif
typedef int16_t code_type;
typedef SIMD<code_type, 16> mesg_type;
typedef DSP::Const<value> Const;
static const int guard_len = rate / 100;
static const int symbol_len = guard_len * 16;
@ -387,11 +383,8 @@ struct Decoder
np += norm(error);
}
value precision = sp / np;
// precision = 8;
value snr = DSP::decibel(precision);
std::cerr << " " << snr;
if (std::is_same<code_type, int8_t>::value && precision > 32)
precision = 32;
for (int i = 0; i < tone_count; ++i) {
if (i % block_length == poff)
continue;

6
psk.hh
View file

@ -27,6 +27,8 @@ struct PhaseShiftKeying<2, TYPE, CODE>
value = std::nearbyint(value);
if (std::is_same<code_type, int8_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -127), 127);
if (std::is_same<code_type, int16_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -32767), 32767);
return value;
}
@ -66,6 +68,8 @@ struct PhaseShiftKeying<4, TYPE, CODE>
value = std::nearbyint(value);
if (std::is_same<code_type, int8_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -127), 127);
if (std::is_same<code_type, int16_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -32767), 32767);
return value;
}
@ -112,6 +116,8 @@ struct PhaseShiftKeying<8, TYPE, CODE>
value = std::nearbyint(value);
if (std::is_same<code_type, int8_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -127), 127);
if (std::is_same<code_type, int16_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -32767), 32767);
return value;
}

8
qam.hh
View file

@ -36,6 +36,8 @@ struct QuadratureAmplitudeModulation<16, TYPE, CODE>
value = std::nearbyint(value);
if (std::is_same<code_type, int8_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -127), 127);
if (std::is_same<code_type, int16_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -32767), 32767);
return value;
}
@ -90,6 +92,8 @@ struct QuadratureAmplitudeModulation<64, TYPE, CODE>
value = std::nearbyint(value);
if (std::is_same<code_type, int8_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -127), 127);
if (std::is_same<code_type, int16_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -32767), 32767);
return value;
}
@ -148,6 +152,8 @@ struct QuadratureAmplitudeModulation<256, TYPE, CODE>
value = std::nearbyint(value);
if (std::is_same<code_type, int8_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -127), 127);
if (std::is_same<code_type, int16_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -32767), 32767);
return value;
}
@ -210,6 +216,8 @@ struct QuadratureAmplitudeModulation<1024, TYPE, CODE>
value = std::nearbyint(value);
if (std::is_same<code_type, int8_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -127), 127);
if (std::is_same<code_type, int16_t>::value)
value = std::min<value_type>(std::max<value_type>(value, -32767), 32767);
return value;
}