summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/src/bitloading.c
diff options
context:
space:
mode:
authorJérémy Dufour2011-08-31 14:48:27 +0200
committerJérémy Dufour2011-11-17 14:03:34 +0100
commit27f90037bfc5db5b99941ba6360bd7616230f742 (patch)
tree4849a3f75087c179aed7ab87cb22217434865b50 /cesar/ce/rx/bitloading/src/bitloading.c
parent1a59e72ca1f2e073e5731dd446f51f7af9adb341 (diff)
cesar/ce/rx/bl: truncate BER before computing BER weighted sum, closes #2696
Diffstat (limited to 'cesar/ce/rx/bitloading/src/bitloading.c')
-rw-r--r--cesar/ce/rx/bitloading/src/bitloading.c61
1 files changed, 45 insertions, 16 deletions
diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c
index d09061fac6..e57b8b576c 100644
--- a/cesar/ce/rx/bitloading/src/bitloading.c
+++ b/cesar/ce/rx/bitloading/src/bitloading.c
@@ -12,6 +12,7 @@
*/
#include "common/std.h"
#include "lib/blk_table.h"
+#include "lib/fixed.h"
#include "ce_rx_bl_fsm_defs.h"
#include "ce/rx/bitloading/inc/ber.h"
#include "ce/rx/bitloading/inc/bitloading.h"
@@ -35,6 +36,19 @@ uint ce_rx_bl_ber_lower_bound_ = 70;
*/
uint ce_rx_bl_pberr_mean_init_ = 655;
+/**
+ * Number of LSB to remove of the BER to compute the BER weighted sum.
+ * It corresponds to the sum of BER weighted by the number of bits of a tone:
+ * - BER is a Q53U53,
+ * - bits of a tone is a Q0U4,
+ * - tone by symbol is a Q0U11.
+ *
+ * To compute the BER weighted sum, we need to reduce to the BER to a Q49U49
+ * (by removing enough LSB).
+ * The BER weighted sum will be a Q49U64.
+ */
+#define CE_RX_BL_BER_WEIGHTED_SUM_SHIFT (4)
+
blk_t *
ce_rx_bl_get_nsr (ce_rx_bitloading_t *bl)
{
@@ -75,7 +89,7 @@ ce_rx_bl_update_tone_map_under_ber_consign (u64 ber_pt,
dbg_assert (tone_en);
u8 modulation;
- u64 ber_weighted_sum = 0;
+ u64 ber_weighted_sum_q49 = 0;
u64 ber_upper;
uint i = 0, carrier_index = 0;
blk_t *cur_blk = bl->noise_nrj;
@@ -113,7 +127,10 @@ ce_rx_bl_update_tone_map_under_ber_consign (u64 ber_pt,
/* Update statistics for this tone map. */
if (modulation)
(*tone_en)++;
- ber_weighted_sum += opti_table[i].ber_lower * CE_BIT_PER_MOD[modulation];
+ ber_weighted_sum_q49 +=
+ fixed_round_64 (opti_table[i].ber_lower,
+ CE_RX_BL_BER_WEIGHTED_SUM_SHIFT)
+ * CE_BIT_PER_MOD[modulation];
tm->bits_per_symbol += CE_BIT_PER_MOD[modulation];
i++;
}
@@ -140,7 +157,7 @@ ce_rx_bl_update_tone_map_under_ber_consign (u64 ber_pt,
}
TONEMAP_ACCESS_END;
- return ber_weighted_sum;
+ return ber_weighted_sum_q49;
}
u16
@@ -149,7 +166,7 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
ce_rx_bitloading_t *bl,
tonemap_t *tm,
ce_rx_bl_ber_impact_t *opti,
- u64 *ber_weighted_sum,
+ u64 *ber_weighted_sum_q49,
uint *tone_en)
{
/* Check parameters. */
@@ -159,15 +176,16 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
dbg_assert (bl);
dbg_assert (opti);
dbg_assert (tone_en);
- dbg_assert (ber_weighted_sum);
+ dbg_assert (ber_weighted_sum_q49);
uint pos = 0;
u32 *tone_word;
s8 mod = -1;
+ u64 ber_pt_q49 = fixed_round_64 (ber_pt, CE_RX_BL_BER_WEIGHTED_SUM_SHIFT);
/* Optimize tone map until we reach the BER consign or we are out of
* table. */
- while (ber_pt * tm->bits_per_symbol >= *ber_weighted_sum
+ while (ber_pt_q49 * tm->bits_per_symbol >= *ber_weighted_sum_q49
&& pos < tonemask->carrier_nb)
{
/* Get the modulation of the lowest BER impact. */
@@ -180,15 +198,20 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
/* Remove from number of bits of the tone map the current value. */
tm->bits_per_symbol -= CE_BIT_PER_MOD[mod];
/* Remove from the summed BER of the tone map the current value. */
- *ber_weighted_sum -= opti[pos].ber_lower * CE_BIT_PER_MOD[mod];
+ *ber_weighted_sum_q49 -=
+ fixed_round_64 (opti[pos].ber_lower,
+ CE_RX_BL_BER_WEIGHTED_SUM_SHIFT)
+ * CE_BIT_PER_MOD[mod];
/* Increase modulation of this tone index. */
tonemap_write_tone_to_word (tone_word, opti[pos].carrier_index,
++mod);
/* Update number of bits of the tone map. */
tm->bits_per_symbol += CE_BIT_PER_MOD[mod];
/* Update summed BER of the tone map. */
- *ber_weighted_sum += (opti[pos].ber_lower
- + ((u64) opti[pos].ber_diff << 32))
+ *ber_weighted_sum_q49 +=
+ fixed_round_64 (opti[pos].ber_lower
+ + ((u64) opti[pos].ber_diff << 32),
+ CE_RX_BL_BER_WEIGHTED_SUM_SHIFT)
* CE_BIT_PER_MOD[mod];
/* Update tone enabled count if needed. */
if (mod == 1)
@@ -199,21 +222,26 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
/* Sanity check: we must have done something! */
dbg_assert (mod != -1);
/* Remove last tone if we are over target. */
- if (*ber_weighted_sum > ber_pt * tm->bits_per_symbol)
+ if (*ber_weighted_sum_q49 > ber_pt_q49 * tm->bits_per_symbol)
{
/* Go back to last position. */
pos--;
dbg_assert (pos < tonemask->carrier_nb);
/* Remove last one. */
tm->bits_per_symbol -= CE_BIT_PER_MOD[mod];
- *ber_weighted_sum -= (opti[pos].ber_lower
- + ((u64) opti[pos].ber_diff << 32))
+ *ber_weighted_sum_q49 -=
+ fixed_round_64 (opti[pos].ber_lower
+ + ((u64) opti[pos].ber_diff << 32),
+ CE_RX_BL_BER_WEIGHTED_SUM_SHIFT)
* CE_BIT_PER_MOD[mod];
/* Write new value. */
tonemap_write_tone_to_word (tone_word, opti[pos].carrier_index,
--mod);
tm->bits_per_symbol += CE_BIT_PER_MOD[mod];
- *ber_weighted_sum += opti[pos].ber_lower * CE_BIT_PER_MOD[mod];
+ *ber_weighted_sum_q49 +=
+ fixed_round_64 (opti[pos].ber_lower,
+ CE_RX_BL_BER_WEIGHTED_SUM_SHIFT)
+ * CE_BIT_PER_MOD[mod];
if (mod == 0)
(*tone_en)--;
}
@@ -263,7 +291,7 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
do
{
/* Make the tone map reach the BER consign, no optimization. */
- u64 ber_weighted_sum =
+ u64 ber_weighted_sum_q49 =
ce_rx_bl_update_tone_map_under_ber_consign (ber_cur, tonemask,
fec_rate, bl,
tm[fec_rate],
@@ -280,7 +308,7 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
bl,
tm[fec_rate],
opti[fec_rate],
- &ber_weighted_sum,
+ &ber_weighted_sum_q49,
&tone_en);
/* Store previous BER consign. */
ber_prev[fec_rate] = ber_cur;
@@ -290,7 +318,8 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
{
/* Store BER target reached. */
ber_reached[fec_rate] =
- ber_weighted_sum / tm[fec_rate]->bits_per_symbol;
+ (ber_weighted_sum_q49 << CE_RX_BL_BER_WEIGHTED_SUM_SHIFT)
+ / tm[fec_rate]->bits_per_symbol;
/* Get new BER consign. */
ber_cur =
ce_rx_bl_ber_pt_bpt (fec_rate,