From 6045870288ffffff54f0bc1fa5c4db9ac4a505bf Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Mon, 15 Jun 2020 07:33:21 +0200 Subject: [PATCH] added BCH(31, 16) T=3 for testing --- tests/short_bch_code_decoder_test.cc | 13 +++++++++++++ tests/short_bch_code_encoder_test.cc | 4 ++++ tests/short_bch_code_regression_test.cc | 4 ++++ tests/soft_bch_regression_test.cc | 9 +++++++++ 4 files changed, 30 insertions(+) diff --git a/tests/short_bch_code_decoder_test.cc b/tests/short_bch_code_decoder_test.cc index b0174cb..cdb22b6 100644 --- a/tests/short_bch_code_decoder_test.cc +++ b/tests/short_bch_code_decoder_test.cc @@ -53,6 +53,19 @@ int main() int recovered = decode(damaged); assert(recovered == target); } + if (1) { + // BCH(31, 16) T=3 + const int N = 31, K = 16, T = 3, POLY = 0b1000111110101111; + CODE::ShortBCHCodeDecoder decode; + int target = 970576025; + int damaged = target; + typedef std::uniform_int_distribution distribution; + auto epos = std::bind(distribution(0, N-1), generator); + for (int i = 0; i < T; ++i) + damaged ^= 1 << epos(); + int recovered = decode(damaged); + assert(recovered == target); + } std::cerr << "Short BCH code decoder test passed!" << std::endl; return 0; } diff --git a/tests/short_bch_code_encoder_test.cc b/tests/short_bch_code_encoder_test.cc index 9b98d71..637754d 100644 --- a/tests/short_bch_code_encoder_test.cc +++ b/tests/short_bch_code_encoder_test.cc @@ -54,6 +54,10 @@ int main() // NASA INTRO BCH(15, 5) T=3 bch_test<15, 5, 3, 0b10100110111>(0b11001, 0b110010001111010); } + if (1) { + // BCH(31, 16) T=3 + bch_test<31, 16, 3, 0b1000111110101111>(29619, 970576025); + } std::cerr << "Short BCH code encoder test passed!" << std::endl; return 0; } diff --git a/tests/short_bch_code_regression_test.cc b/tests/short_bch_code_regression_test.cc index 84c152d..2df1b75 100644 --- a/tests/short_bch_code_regression_test.cc +++ b/tests/short_bch_code_regression_test.cc @@ -49,6 +49,10 @@ int main() // NASA INTRO BCH(15, 5) T=3 bch_test<15, 5, 3, 0b10100110111>(1000000); } + if (1) { + // BCH(31, 16) T=3 + bch_test<31, 16, 3, 0b1000111110101111>(1000000); + } std::cerr << "Short BCH code regression test passed!" << std::endl; return 0; } diff --git a/tests/soft_bch_regression_test.cc b/tests/soft_bch_regression_test.cc index f762ce7..cc03d71 100644 --- a/tests/soft_bch_regression_test.cc +++ b/tests/soft_bch_regression_test.cc @@ -51,6 +51,15 @@ int popcnt(TYPE x) const int RADIUS_T = 3; const int GEN_POLY = 0b10100110111; #endif +#if 0 + // BCH(31, 16) T=3 + const int LOOPS = 50000; + const float QEF_SNR = 6.5; + const int CODE_LEN = 31; + const int DATA_LEN = 16; + const int RADIUS_T = 3; + const int GEN_POLY = 0b1000111110101111; +#endif int main() {