summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/test/src/test_bl.c
diff options
context:
space:
mode:
authorJalil Chemseddine2012-06-12 15:09:42 +0200
committerJalil Chemseddine2012-06-20 15:41:03 +0200
commit792b9ed42008e4d682b3efd4197eca961944fa3e (patch)
treeb994a9d949197395d58f7e050b005b6a661eb6d1 /cesar/ce/rx/bitloading/test/src/test_bl.c
parentfd43428ce1580b21eae6f33a70fffb73db375b5b (diff)
cesar/ce/rx add new tone mask to handle faulty carriers, closes #3095
Add a new tone mask which disable faulty carriers in CE bit-loading computation. This tone mask differs from the general tone mask in the station and is only used in bit-loading.
Diffstat (limited to 'cesar/ce/rx/bitloading/test/src/test_bl.c')
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_bl.c119
1 files changed, 116 insertions, 3 deletions
diff --git a/cesar/ce/rx/bitloading/test/src/test_bl.c b/cesar/ce/rx/bitloading/test/src/test_bl.c
index bfdb5f67e3..2c28b6ec2f 100644
--- a/cesar/ce/rx/bitloading/test/src/test_bl.c
+++ b/cesar/ce/rx/bitloading/test/src/test_bl.c
@@ -23,6 +23,7 @@
#include "ce/rx/bitloading/bitloading.h"
#include "ce/rx/bitloading/inc/common.h"
#include "ce/rx/bitloading/nsr.h"
+#include "ce/rx/tonemask.h"
#include "lib/rnd.h"
/* Test vectors. */
@@ -31,6 +32,7 @@
#include "nsr_on_sound_max.h"
#include "mean_on_sound_nsr.h"
#include "bl_initial_final.h"
+#include "bl_initial_final_with_carriers_masked.h"
#include "polynomial_nsr.h"
#include "polynomial_raw.h"
#include "tonemap_initial_0db_nsr_margin_0_00_ber_margin.h"
@@ -609,7 +611,7 @@ test_suite_ce_rx_bl_initial (test_t t)
ce_rx_bl_nsr_compute_mean (&bl);
/* Test tone map iterative with this special NSR. */
- tonemap_t *tm = ce_rx_bl_initial (&ti, &bl);
+ tonemap_t *tm = ce_rx_bl_initial (&ti, &ti, &bl);
test_fail_if (tm != NULL);
/* Clean. */
@@ -629,7 +631,7 @@ test_suite_ce_rx_bl_initial (test_t t)
s64 nsr_prev = -1;
uint nsr_diff = 0;
uint bit_per_tone = 0, bit_per_tone_vect = 0;
- tonemap_t *tm = ce_rx_bl_initial (&ti, &bl);
+ tonemap_t *tm = ce_rx_bl_initial (&ti, &ti, &bl);
uint tone, i = 0;
#define TONEMAP_READ_OPEN {
#define TONEMAP_READ_CLOSE }
@@ -672,6 +674,117 @@ test_suite_ce_rx_bl_initial (test_t t)
/* Clean. */
test_bl_after_nsr_sound_uninit (&bl);
} test_end;
+
+ test_begin (t, "generation initial tone map with first two carriers "
+ "after PHY_CARRIER_OFFSET masked")
+ {
+ ce_rx_bitloading_t bl;
+ /* Go until computation of mean. */
+ test_bl_after_nsr_sound_init (&bl);
+ tonemask_info_t ti, modified_ti;
+ ti.carrier_nb = tonemask_default (ti.tonemask);
+ ce_rx_tonemask_init (&modified_ti);
+
+ uint tone_diff = 0;
+ s64 nsr_prev = -1;
+ uint nsr_diff = 0;
+ uint bit_per_tone = 0, bit_per_tone_vect = 0;
+ tonemap_t *tm = ce_rx_bl_initial (&ti, &modified_ti, &bl);
+ uint tone, i = 0;
+#define TONEMAP_READ_OPEN {
+#define TONEMAP_READ_CLOSE }
+ TONEMAP_READ_BEGIN (tm, ti.tonemask, tone)
+ {
+ if (CE_BIT_PER_MOD[tone] != bl_initial_final_with_carriers_masked[i][0])
+ {
+ /* Modulation differs. */
+ tone_diff++;
+ /* Is it a sort problem of same NSR? */
+ /* Initialize NSR prev the first time. */
+ if (nsr_prev == -1)
+ nsr_prev = mean_on_sound_nsr[i][0];
+ /* Check if not first time. */
+ else if (nsr_prev != mean_on_sound_nsr[i][0])
+ nsr_diff++;
+ }
+ /* Compute bit of this tone map. */
+ bit_per_tone_vect += bl_initial_final_with_carriers_masked[i][0];
+ bit_per_tone += CE_BIT_PER_MOD[tone];
+ i++;
+ }
+ TONEMAP_READ_CLOSE
+ else
+ TONEMAP_READ_OPEN
+ {
+ i++;
+ }
+ TONEMAP_READ_END;
+#undef TONEMAP_READ_OPEN
+#undef TONEMAP_READ_CLOSE
+ tonemap_free (tm);
+ test_fail_if (tm->fecrate != PHY_FEC_RATE_16_21);
+ test_fail_if (bit_per_tone != bit_per_tone_vect);
+ test_fail_if (tone_diff > TONE_TOLERATED_ERROR, "%d computed "
+ "tone(s) differs from test vector", tone_diff);
+ if (tone_diff)
+ test_fail_if (nsr_diff != 0);
+
+ /* Clean. */
+ test_bl_after_nsr_sound_uninit (&bl);
+ } test_end;
+
+ test_begin (t, "generation initial tone map with modified tonemask")
+ {
+ ce_rx_bitloading_t bl;
+ /* Go until computation of mean. */
+ test_bl_after_nsr_sound_init (&bl);
+ tonemask_info_t ti, modified_ti;
+ uint i;
+ ti.carrier_nb = tonemask_default (ti.tonemask);
+ ce_rx_tonemask_init (&modified_ti);
+
+ for (i = 0; i < PHY_TONEMASK_WORDS - 1; i++)
+ {
+ modified_ti.tonemask[i] = i % 2 ? BITS_ONES (32) : 0;
+ }
+ modified_ti.tonemask[i] = BITS_ONES (32);
+
+ tonemap_t *tm = ce_rx_bl_initial (&ti, &modified_ti, &bl);
+ uint tone;
+ bool masked = false;
+ i = 0;
+#define TONEMAP_READ_OPEN {
+#define TONEMAP_READ_CLOSE }
+ TONEMAP_READ_BEGIN (tm, ti.tonemask, tone)
+ {
+ if (masked)
+ {
+ test_fail_if (tone != 0, "%d", i);
+ }
+ i++;
+ if (!(i % 32))
+ masked = !masked;
+ if (i == PHY_TONEMASK_WORDS * 32)
+ masked = true;
+ }
+ TONEMAP_READ_CLOSE
+ else
+ TONEMAP_READ_OPEN
+ {
+ i++;
+ if (!(i % 32))
+ masked = !masked;
+ if (i == PHY_TONEMASK_WORDS * 32)
+ masked = true;
+ }
+ TONEMAP_READ_END;
+#undef TONEMAP_READ_OPEN
+#undef TONEMAP_READ_CLOSE
+ tonemap_free (tm);
+
+ /* Clean. */
+ test_bl_after_nsr_sound_uninit (&bl);
+ } test_end;
}
/**
@@ -1173,7 +1286,7 @@ test_suite_ce_rx_bl_tm_configuration (test_t t)
test_begin (t, "tone map contention period usage flag enabled")
{
- tonemap_t *tm = ce_rx_bl_initial (&ti, &bl);
+ tonemap_t *tm = ce_rx_bl_initial (&ti, &ti, &bl);
dbg_assert (tm);
test_fail_if (tm->cpf != true);
tonemap_free (tm);