summaryrefslogtreecommitdiff
path: root/cesar/ce/rx
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/ce/rx')
-rw-r--r--cesar/ce/rx/Module2
-rw-r--r--cesar/ce/rx/bitloading/inc/bitloading.h3
-rw-r--r--cesar/ce/rx/bitloading/inc/initial.h5
-rw-r--r--cesar/ce/rx/bitloading/src/bitloading.c10
-rw-r--r--cesar/ce/rx/bitloading/src/common.c3
-rw-r--r--cesar/ce/rx/bitloading/src/initial.c5
-rw-r--r--cesar/ce/rx/bitloading/test/common-define.mk3
-rw-r--r--cesar/ce/rx/bitloading/test/data/bl_initial_final_with_carriers_masked.data1536
-rw-r--r--cesar/ce/rx/bitloading/test/host-Makefile4
-rw-r--r--cesar/ce/rx/bitloading/test/sparc-Makefile4
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_bl.c119
-rw-r--r--cesar/ce/rx/inc/rx.h4
-rw-r--r--cesar/ce/rx/src/rx.c4
-rw-r--r--cesar/ce/rx/src/tonemask.c26
-rw-r--r--cesar/ce/rx/tonemask.h29
15 files changed, 1742 insertions, 15 deletions
diff --git a/cesar/ce/rx/Module b/cesar/ce/rx/Module
index 02bfd0b486..b865649712 100644
--- a/cesar/ce/rx/Module
+++ b/cesar/ce/rx/Module
@@ -1,5 +1,5 @@
# Channel Estimation (CE) in Receive (RX) mode.
-SOURCES := rx.c measure.c
+SOURCES := rx.c measure.c tonemask.c
ifeq ($(CONFIG_TRACE),y)
SOURCES += trace.c
endif
diff --git a/cesar/ce/rx/bitloading/inc/bitloading.h b/cesar/ce/rx/bitloading/inc/bitloading.h
index b6f2a658b3..b57269a333 100644
--- a/cesar/ce/rx/bitloading/inc/bitloading.h
+++ b/cesar/ce/rx/bitloading/inc/bitloading.h
@@ -147,6 +147,8 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
* consign).
* \param iteration_max maximum number of iteration.
* \param tonemask the tone mask context.
+ * \param reducedtm extra tone mask context used to mask faulty carriers
+ * during tonemap generation. Can be the same as tonemask.
* \param bl the bit loading context.
* \return the computed tone map or NULL if no tone map computation is
* possible.
@@ -164,6 +166,7 @@ tonemap_t *
ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
uint iteration_max,
tonemask_info_t *tonemask,
+ tonemask_info_t *reducedtm,
ce_rx_bitloading_t *bl);
/**
diff --git a/cesar/ce/rx/bitloading/inc/initial.h b/cesar/ce/rx/bitloading/inc/initial.h
index 05802894e5..d56013e294 100644
--- a/cesar/ce/rx/bitloading/inc/initial.h
+++ b/cesar/ce/rx/bitloading/inc/initial.h
@@ -24,6 +24,8 @@ BEGIN_DECLS
/**
* Generate an initial tone map.
* \param tonemask the tone mask context.
+ * \param reducedtm extra tone mask context used to mask faulty carriers
+ * during tonemap generation. Can be the same as tonemask.
* \param bl the bit loading context.
* \return the optimized tone map (iterative version) or NULL when the
* computation is impossible.
@@ -32,7 +34,8 @@ BEGIN_DECLS
* loading algorithm.
*/
tonemap_t *
-ce_rx_bl_initial (tonemask_info_t *tonemask, ce_rx_bitloading_t *bl);
+ce_rx_bl_initial (tonemask_info_t *tonemask, tonemask_info_t *reducedtm,
+ ce_rx_bitloading_t *bl);
END_DECLS
diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c
index 614c3e0628..948487fa6e 100644
--- a/cesar/ce/rx/bitloading/src/bitloading.c
+++ b/cesar/ce/rx/bitloading/src/bitloading.c
@@ -255,6 +255,7 @@ tonemap_t *
ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
uint iteration_max,
tonemask_info_t *tonemask,
+ tonemask_info_t *reducedtm,
ce_rx_bitloading_t *bl)
{
/* Check parameters. */
@@ -267,6 +268,7 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
/* Dynamic table size is not possible (because of compiler bug on stack).
* For the moment being we use a define (even if table is too big). */
dbg_assert (tonemask && tonemask->carrier_nb <= PHY_CARRIER_NB);
+ dbg_assert (reducedtm && reducedtm->carrier_nb <= PHY_CARRIER_NB);
ce_rx_bl_ber_impact_t opti[PHY_FEC_RATE_NB][PHY_CARRIER_NB];
u16 opti_cursor[PHY_FEC_RATE_NB];
uint cpt;
@@ -295,19 +297,19 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
{
/* Make the tone map reach the BER consign, no optimization. */
u64 ber_weighted_sum_q49 =
- ce_rx_bl_update_tone_map_under_ber_consign (ber_cur, tonemask,
+ ce_rx_bl_update_tone_map_under_ber_consign (ber_cur, reducedtm,
fec_rate, bl,
tm[fec_rate],
opti[fec_rate],
&tone_en);
/* Sort optimization table. */
- ce_rx_bl_sort_optimization (opti[fec_rate], tonemask->carrier_nb);
+ ce_rx_bl_sort_optimization (opti[fec_rate], reducedtm->carrier_nb);
/* Optimize tone map to reach BER consign. */
opti_cursor[fec_rate] =
ce_rx_bl_update_tone_map_at_ber_consign (ber_cur,
- tonemask,
+ reducedtm,
bl,
tm[fec_rate],
opti[fec_rate],
@@ -326,7 +328,7 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
/* Get new BER consign. */
ber_cur =
ce_rx_bl_ber_pt_bpt (fec_rate,
- tonemask->carrier_nb,
+ reducedtm->carrier_nb,
(tm[fec_rate]->bits_per_symbol *
CE_RX_BL_BPT_QUANT_FACTOR) / tone_en);
}
diff --git a/cesar/ce/rx/bitloading/src/common.c b/cesar/ce/rx/bitloading/src/common.c
index 0b9c933b63..12a68f3311 100644
--- a/cesar/ce/rx/bitloading/src/common.c
+++ b/cesar/ce/rx/bitloading/src/common.c
@@ -36,7 +36,8 @@ ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, tonemask_info_t *ts)
ce_debug_gpio_event (CE_DEBUG_GPIO_EVENT_CE_RX_BL_WORKING, true);
/* Compute initial tone map. */
- tonemap_t *initial_tm = ce_rx_bl_initial (ts, &sta->ce_rx_bt);
+ tonemap_t *initial_tm = ce_rx_bl_initial (ts, &ce_rx->tonemask,
+ &sta->ce_rx_bt);
/* Dump tone map in trace. */
if (CONFIG_TRACE)
diff --git a/cesar/ce/rx/bitloading/src/initial.c b/cesar/ce/rx/bitloading/src/initial.c
index 82818370d2..30c78869f3 100644
--- a/cesar/ce/rx/bitloading/src/initial.c
+++ b/cesar/ce/rx/bitloading/src/initial.c
@@ -20,9 +20,10 @@
#include "ce/rx/bitloading/inc/initial.h"
tonemap_t *
-ce_rx_bl_initial (tonemask_info_t *tonemask, ce_rx_bitloading_t *bl)
+ce_rx_bl_initial (tonemask_info_t *tonemask, tonemask_info_t *reducedtm,
+ ce_rx_bitloading_t *bl)
{
/* Only one iteration. */
return ce_rx_bl_compute_tone_map_iterative (ce_rx_bl_initial_bpt, 1,
- tonemask, bl);
+ tonemask, reducedtm, bl);
}
diff --git a/cesar/ce/rx/bitloading/test/common-define.mk b/cesar/ce/rx/bitloading/test/common-define.mk
index 1c8e7bd229..a1fb824851 100644
--- a/cesar/ce/rx/bitloading/test/common-define.mk
+++ b/cesar/ce/rx/bitloading/test/common-define.mk
@@ -13,7 +13,8 @@ ce_rx_bl_modules_common = lib \
# Test vectors from TNS.
bl_test_vectors_tns = nsr_on_sound.data mean_on_sound_nsr.data \
- bl_initial_final.data nsr_on_sound_max.data \
+ bl_initial_final.data bl_initial_final_with_carriers_masked.data \
+ nsr_on_sound_max.data \
tonemap_initial_0db_nsr_margin_0_00_ber_margin.data \
tonemap_initial_0db_nsr_margin_0_01_ber_margin.data \
tonemap_initial_1db_nsr_margin_0_00_ber_margin.data \
diff --git a/cesar/ce/rx/bitloading/test/data/bl_initial_final_with_carriers_masked.data b/cesar/ce/rx/bitloading/test/data/bl_initial_final_with_carriers_masked.data
new file mode 100644
index 0000000000..4227b0b9f8
--- /dev/null
+++ b/cesar/ce/rx/bitloading/test/data/bl_initial_final_with_carriers_masked.data
@@ -0,0 +1,1536 @@
+0
+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
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
diff --git a/cesar/ce/rx/bitloading/test/host-Makefile b/cesar/ce/rx/bitloading/test/host-Makefile
index 856652f3d6..a065f5e794 100644
--- a/cesar/ce/rx/bitloading/test/host-Makefile
+++ b/cesar/ce/rx/bitloading/test/host-Makefile
@@ -10,9 +10,11 @@ include common-define.mk
HOST_PROGRAMS = test_ce_host test_ce_intervals
test_ce_host_SOURCES = $(ce_rx_bl_test_sources_common) ecos_stub.c
-test_ce_host_MODULES = $(ce_rx_bl_modules_common)
+test_ce_host_MODULES = $(ce_rx_bl_modules_common) ce/rx
test_ce_host_CONFIG_MODULES = cp
+ce_rx_MODULE_SOURCES = tonemask.c
+
test_ce_intervals_SOURCES = test_intervals.c ecos_stub.c
test_ce_intervals_MODULES = $(ce_rx_bl_modules_common)
test_ce_intervals_CONFIG_MODULES = cp
diff --git a/cesar/ce/rx/bitloading/test/sparc-Makefile b/cesar/ce/rx/bitloading/test/sparc-Makefile
index ccaa7e1633..087e5090db 100644
--- a/cesar/ce/rx/bitloading/test/sparc-Makefile
+++ b/cesar/ce/rx/bitloading/test/sparc-Makefile
@@ -15,9 +15,11 @@ TARGET = sparc
TARGET_PROGRAMS = test_ce_sparc
test_ce_sparc_SOURCES = $(ce_rx_bl_test_sources_common)
-test_ce_sparc_MODULES = $(ce_rx_bl_modules_common) hal/arch
+test_ce_sparc_MODULES = $(ce_rx_bl_modules_common) hal/arch ce/rx
test_ce_sparc_CONFIG_MODULES = cp
+ce_rx_MODULE_SOURCES = tonemask.c
+
# Include base makefile.
include $(BASE)/common/make/top.mk
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);
diff --git a/cesar/ce/rx/inc/rx.h b/cesar/ce/rx/inc/rx.h
index e9b4fcc62c..6f34da968a 100644
--- a/cesar/ce/rx/inc/rx.h
+++ b/cesar/ce/rx/inc/rx.h
@@ -133,6 +133,10 @@ struct ce_rx_t
* Tick per RTC, for eCos timer & co.
*/
u32 tck_per_rtc;
+ /**
+ * Extra tone mask context used to handle faulty carriers.
+ */
+ tonemask_info_t tonemask;
};
/**
diff --git a/cesar/ce/rx/src/rx.c b/cesar/ce/rx/src/rx.c
index 770f5207d0..25c748088f 100644
--- a/cesar/ce/rx/src/rx.c
+++ b/cesar/ce/rx/src/rx.c
@@ -16,6 +16,7 @@
#include "ce/rx/cp/inc/cp.h"
#include "ce/rx/inc/rx.h"
#include "ce/rx/rx.h"
+#include "ce/rx/tonemask.h"
#include "mac/common/timings.h"
#include "mac/common/defs.h"
#include "mac/common/store.h"
@@ -65,6 +66,9 @@ ce_rx_init (mac_store_t *mac_store, sar_t *sar, pbproc_t *pbproc,
ce_rx_measure_init (&ce_rx, sar, pbproc);
/* Initialize communication with the CP. */
ce_rx_cp_init (&ce_rx);
+ /* Initialize extra tonemask to mask faulty carriers
+ * during tonemap generation. */
+ ce_rx_tonemask_init (&ce_rx.tonemask);
/* Register our configuration variables.
* FIXME: this is a dirty hack. */
diff --git a/cesar/ce/rx/src/tonemask.c b/cesar/ce/rx/src/tonemask.c
new file mode 100644
index 0000000000..902909afcc
--- /dev/null
+++ b/cesar/ce/rx/src/tonemask.c
@@ -0,0 +1,26 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/src/tonemask.c
+ * \brief Channel Estimation in Receive mode (tonemask).
+ * \ingroup ce_rx
+ */
+#include "common/std.h"
+#include "ce/rx/tonemask.h"
+
+void
+ce_rx_tonemask_init (tonemask_info_t *ti)
+{
+ /* Check parameter. */
+ dbg_assert (ti);
+
+ ti->carrier_nb = tonemask_default (ti->tonemask);
+
+ /* Disable first two carriers (see maria:#601) */
+ ti->tonemask[0] = ti->tonemask[0] | 0x3;
+}
diff --git a/cesar/ce/rx/tonemask.h b/cesar/ce/rx/tonemask.h
new file mode 100644
index 0000000000..3707286d44
--- /dev/null
+++ b/cesar/ce/rx/tonemask.h
@@ -0,0 +1,29 @@
+#ifndef ce_rx_tonemask_h
+#define ce_rx_tonemask_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/tonemask.h
+ * \brief Channel Estimation in Receive mode (tonemask).
+ * \ingroup ce_rx
+ */
+#include "mac/common/tonemask.h"
+
+BEGIN_DECLS
+
+/**
+ * Initialize extra tonemask to mask faulty carriers during tonemap
+ * generation.
+ * \param ti tonemask info.
+ */
+void
+ce_rx_tonemask_init (tonemask_info_t *ti);
+
+END_DECLS
+
+#endif /* ce_rx_tonemask_h */