summaryrefslogtreecommitdiff
path: root/cesar/mac/common
diff options
context:
space:
mode:
authormercadie2010-05-25 12:43:09 +0000
committermercadie2010-05-25 12:43:09 +0000
commit5e0c9b1f4cdfc0b848359e7b5caf5ebd40e26e7f (patch)
tree61b22780c49777f1773f227629f7a2cfe886e7b8 /cesar/mac/common
parent186a763eb3c97154fbdd19cbd989728eaa9007bc (diff)
cesar/cp/sta/action/misc: compute average ble using tonemap tx, closes #169
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7131 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/mac/common')
-rw-r--r--cesar/mac/common/src/tonemap.c41
-rw-r--r--cesar/mac/common/tonemap.h16
2 files changed, 44 insertions, 13 deletions
diff --git a/cesar/mac/common/src/tonemap.c b/cesar/mac/common/src/tonemap.c
index 4f6d4f4d31..eda0fc9a27 100644
--- a/cesar/mac/common/src/tonemap.c
+++ b/cesar/mac/common/src/tonemap.c
@@ -293,6 +293,33 @@ tonemap_tcc_halfit (uint bits_per_symbol, uint bits_per_pb, phy_gil_t gil)
return MIN (halfit, 31u);
}
+uint
+tonemap_ble_mant_2_uf5 (u8 ble)
+{
+ u8 mant = ble >> 3;
+ u8 exp = ble & ((1 << 3) - 1);
+
+ return (mant + 31) * (1 << (exp + 1)) + (1 << (exp));
+}
+
+u8
+tonemap_ble_uf5_2_mant (uint ble_uf5)
+{
+ if (ble_uf5 >= TONEMAP_BLE_MAX * (1u << 5))
+ return 0xff;
+ else if (ble_uf5 < (2 * (1u << 5)) + 1)
+ return 0;
+ else
+ {
+ uint exp, mant;
+ exp = tonemap_ble_log2 (ble_uf5 >> 5) - 1;
+ dbg_assert (exp < (1u << 3));
+ mant = (ble_uf5 >> (exp + 1)) - 32;
+ dbg_assert (mant < (1u << 5));
+ return mant << 3 | exp;
+ }
+}
+
u8
tonemap_ble (uint bits_per_symbol, phy_fecrate_t fecrate, u32 p_pberror_uf32,
phy_gil_t gil)
@@ -329,19 +356,7 @@ tonemap_ble (uint bits_per_symbol, phy_fecrate_t fecrate, u32 p_pberror_uf32,
dbg_assert_default ();
}
/* Convert to BLE floating point format. */
- if (ble_uf5 >= TONEMAP_BLE_MAX * (1u << 5))
- return 0xff;
- else if (ble_uf5 < (2 * (1u << 5)) + 1)
- return 0;
- else
- {
- uint exp, mant;
- exp = tonemap_ble_log2 (ble_uf5 >> 5) - 1;
- dbg_assert (exp < (1u << 3));
- mant = (ble_uf5 >> (exp + 1)) - 32;
- dbg_assert (mant < (1u << 5));
- return mant << 3 | exp;
- }
+ return tonemap_ble_uf5_2_mant (ble_uf5);
}
void
diff --git a/cesar/mac/common/tonemap.h b/cesar/mac/common/tonemap.h
index 29d14f953e..39b2442b7e 100644
--- a/cesar/mac/common/tonemap.h
+++ b/cesar/mac/common/tonemap.h
@@ -633,6 +633,22 @@ uint
tonemap_tcc_halfit (uint bits_per_symbol, uint bits_per_pb, phy_gil_t gil);
/**
+ * Convert ble in FC representation to floating point representation.
+ * \param ble ble in FC representation (5 bits mantissa, 3 bits exponent)
+ * \return ble in floating point representation (real value << 5)
+ */
+uint
+tonemap_ble_mant_2_uf5 (u8 ble);
+
+/**
+ * Convert ble in floating point representation to FC representation.
+ * \param ble ble in floating point representation (real value << 5)
+ * \return ble in FC representation (5 bits mantissa, 3 bits exponent)
+ */
+u8
+tonemap_ble_uf5_2_mant (uint ble);
+
+/**
* Compute floating point representation of BLE for frame control field.
* \param bits_per_symbol number of bits per symbol
* \param fecrate FEC encoding rate