summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/src/bitloading.c
diff options
context:
space:
mode:
authordufour2010-01-26 14:01:09 +0000
committerdufour2010-01-26 14:01:09 +0000
commit63f3d76c896ab1c533dc8a244d143bacfe6d617d (patch)
tree47fd838486a328594dd84abe77bc537e9e8177f9 /cesar/ce/rx/bitloading/src/bitloading.c
parentf98f4150523e924d89deb4b39cbb1cda190c4028 (diff)
cesar/ce/rx/bitloading: minor fixes (documentation, assert, indentation)
This commit does not really change anything in the behavior of the code: - remove unused asserts and add required one, - update comments to correspond to code, - fix doxygen comments, - fix indentation. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6654 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce/rx/bitloading/src/bitloading.c')
-rw-r--r--cesar/ce/rx/bitloading/src/bitloading.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c
index b9700d3be0..96ff2a2362 100644
--- a/cesar/ce/rx/bitloading/src/bitloading.c
+++ b/cesar/ce/rx/bitloading/src/bitloading.c
@@ -28,6 +28,7 @@ ce_rx_bl_get_nsr (ce_rx_bitloading_t *bl)
switch (bl->fsm)
{
+ /* We can only get noise after bit loading initial. */
case CE_RX_BL_FSM_STATE_TRACKING:
return bl->noise_nrj;
break;
@@ -39,11 +40,8 @@ ce_rx_bl_get_nsr (ce_rx_bitloading_t *bl)
void
ce_rx_bl_sort_optimization (ce_rx_bl_ber_impact_t *opti_table,
- uint size)
+ uint size)
{
- /* Check parameter. */
- dbg_assert (opti_table);
-
lib_heapsort (opti_table, size);
}
@@ -57,7 +55,6 @@ ce_rx_bl_update_tone_map_under_ber_consign (u64 ber_pt,
uint *tone_en)
{
/* Check parameters. */
- dbg_assert (ber_pt > 0 && ber_pt < CE_RX_BL_BER_DEFAULT_OVER);
dbg_assert (tonemask);
dbg_assert (tm);
dbg_assert (opti_table);
@@ -91,14 +88,17 @@ ce_rx_bl_update_tone_map_under_ber_consign (u64 ber_pt,
ce_rx_bl_ber_vs_nsr (ce_rx_bl_ber_poly_coef[fec_rate],
nsr_data[carrier_index % (BLK_SIZE / 4)], ber_pt,
&modulation, &opti_table[i].ber_lower, &ber_upper);
- /* Fill temporary table. */
- if (modulation)
- (*tone_en)++;
+ /* Update optimization table. */
if (modulation == CE_MOD_COUNT - 1)
+ /* This tone can not be improved, set an impossible BER
+ * difference. */
opti_table[i].ber_diff = -1;
else
opti_table[i].ber_diff = (ber_upper - opti_table[i].ber_lower) >> 32;
opti_table[i].carrier_index = carrier_index;
+ /* Update statistics for this tone map. */
+ if (modulation)
+ (*tone_en)++;
ber_weighted_sum += opti_table[i].ber_lower * CE_BIT_PER_MOD[modulation];
tm->bits_per_symbol += CE_BIT_PER_MOD[modulation];
i++;
@@ -146,7 +146,7 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
uint tone_en;
- /* Generate a non optimized version of the initial tone map. */
+ /* Make the tone map reach the BER consign without optimization. */
u64 ber_weighted_sum =
ce_rx_bl_update_tone_map_under_ber_consign (ber_pt, tonemask,
fec_rate, bl, tm, opti,
@@ -155,16 +155,15 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
/* Sort optimization table. */
ce_rx_bl_sort_optimization (opti, tonemask->carrier_nb);
- /* Until we reach the limit. */
uint pos = 0;
u32 *tone_word;
s8 mod = -1;
+
+ /* Optimize table until we reach the BER consign. */
while (ber_pt * tm->bits_per_symbol >= ber_weighted_sum)
{
/* Get the modulation of the lowest BER impact. */
mod = tonemap_get_tone (tm, opti[pos].carrier_index, &tone_word);
- if (mod == 0)
- tone_en++;
/* If the tone we would like to increase is already at its maximum,
* all the remaining tone that can be increase are already at the
* maximum too. So basically, we should stop the algorithm here. */
@@ -182,9 +181,13 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
/* Update summed BER of the tone map. */
ber_weighted_sum += (opti[pos].ber_lower + ((u64) opti[pos].ber_diff << 32))
* CE_BIT_PER_MOD[mod];
+ /* Update tone enabled count if needed. */
+ if (mod == 1)
+ tone_en++;
/* Next one. */
pos++;
}
+ /* Sanity check: we must have done something! */
dbg_assert (mod != -1);
/* Remove last one. */
tm->bits_per_symbol -= CE_BIT_PER_MOD[mod];
@@ -193,6 +196,7 @@ ce_rx_bl_update_tone_map_at_ber_consign (u64 ber_pt,
tm->bits_per_symbol += CE_BIT_PER_MOD[mod];
if (mod == 0)
tone_en--;
+ /* Return number of tones enabled. */
return tone_en;
}
@@ -205,8 +209,6 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
/* Check parameters. */
dbg_assert (bpt_initial);
dbg_assert (iteration_max);
- dbg_assert (tonemask);
- dbg_assert (bl);
u64 ber_prev, ber_cur;
uint it_count;
@@ -219,14 +221,15 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
/* For each FEC rate. */
for (fec_rate = PHY_FEC_RATE_1_2; fec_rate < PHY_FEC_RATE_NB; fec_rate++)
{
+ /* Initialize. */
it_count = 0;
+ /* Allocate a tone map for this FEC rate. */
tm[fec_rate] = tonemap_alloc ();
- /* Start with the lowest BER consign possible (it depends on the FEC
- * rate). */
+ /* Get initial BER consign from initial bits per tone. */
ber_cur = ce_rx_bl_ber_pt_bpt (fec_rate, bpt_initial[fec_rate]);
do
{
- /* Generate a optimized version of the tone map. */
+ /* Optimize tone map to reach BER consign. */
tone_en = ce_rx_bl_update_tone_map_at_ber_consign
(ber_cur, tonemask, fec_rate, bl, tm[fec_rate], opti);
/* Store previous BER consign. */
@@ -236,13 +239,14 @@ ce_rx_bl_compute_tone_map_iterative (const u64 bpt_initial[PHY_FEC_RATE_NB],
(fec_rate, (tm[fec_rate]->bits_per_symbol *
CE_RX_BL_BPT_QUANT_FACTOR) / tone_en);
}
- /* Repeat until no modification of the BER consign (or 6 times). */
+ /* Repeat until no modification of the BER consign or until maximum
+ * number of iterations is reached. */
while (++it_count < iteration_max && ber_prev != ber_cur);
- /* Store tone map generated. */
+ /* Store generated tone map. */
sort[fec_rate] = tm[fec_rate]->bits_per_symbol;
}
- /* Choose best fec_rate. */
+ /* Choose best tone map depending on FEC rate. */
/* 1/2 * 42 -> 21.
* 16/21 * 42 -> 32. */
phy_fecrate_t good, bad;