提交 e58b2e7d authored 作者: Steve Underwood's avatar Steve Underwood

Some modem cleanups, and movement towards efficient fixed point modem

implementations for platforms with slow floating point
上级 5922cb59
......@@ -26,10 +26,10 @@
#if !defined(_SPANDSP_PRIVATE_V22BIS_H_)
#define _SPANDSP_PRIVATE_V22BIS_H_
/*! The number of steps to the left and to the right of the target position in the equalizer buffer. */
#define V22BIS_EQUALIZER_LEN 7
/*! One less than a power of 2 >= (2*V22BIS_EQUALIZER_LEN + 1) */
#define V22BIS_EQUALIZER_MASK 15
/*! The length of the equalizer buffer */
#define V22BIS_EQUALIZER_LEN 17
/*! Samples before the target position in the equalizer buffer */
#define V22BIS_EQUALIZER_PRE_LEN 8
/*! The number of taps in the transmit pulse shaping filter */
#define V22BIS_TX_FILTER_STEPS 9
......@@ -139,24 +139,24 @@ struct v22bis_state_s
#if defined(SPANDSP_USE_FIXED_POINTx)
/*! \brief The scaling factor accessed by the AGC algorithm. */
float agc_scaling;
int16_t agc_scaling;
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
int16_t rrc_filter[V22BIS_RX_FILTER_STEPS];
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
int16_t eq_delta;
/*! \brief The adaptive equalizer coefficients. */
complexi_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1];
complexi16_t eq_coeff[V22BIS_EQUALIZER_LEN];
/*! \brief The equalizer signal buffer. */
complexi_t eq_buf[V22BIS_EQUALIZER_MASK + 1];
complexi16_t eq_buf[V22BIS_EQUALIZER_LEN];
/*! \brief A measure of how much mismatch there is between the real constellation,
and the decoded symbol positions. */
float training_error;
int32_t training_error;
/*! \brief The proportional part of the carrier tracking filter. */
float carrier_track_p;
int32_t carrier_track_p;
/*! \brief The integral part of the carrier tracking filter. */
float carrier_track_i;
int32_t carrier_track_i;
#else
/*! \brief The scaling factor accessed by the AGC algorithm. */
float agc_scaling;
......@@ -166,9 +166,9 @@ struct v22bis_state_s
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
/*! \brief The adaptive equalizer coefficients. */
complexf_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1];
complexf_t eq_coeff[V22BIS_EQUALIZER_LEN];
/*! \brief The equalizer signal buffer. */
complexf_t eq_buf[V22BIS_EQUALIZER_MASK + 1];
complexf_t eq_buf[V22BIS_EQUALIZER_LEN];
/*! \brief A measure of how much mismatch there is between the real constellation,
and the decoded symbol positions. */
......@@ -202,7 +202,7 @@ struct v22bis_state_s
/* Transmit section */
struct
{
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
/*! \brief The guard tone level. */
int16_t guard_tone_gain;
/*! \brief The gain factor needed to achieve the specified output power. */
......
......@@ -76,22 +76,22 @@ struct v27ter_rx_state_s
int16_t agc_scaling_save;
/*! \brief The current delta factor for updating the equalizer coefficients. */
float eq_delta;
int16_t eq_delta;
/*! \brief The adaptive equalizer coefficients. */
/*complexi16_t*/ complexf_t eq_coeff[V27TER_EQUALIZER_LEN];
complexi16_t eq_coeff[V27TER_EQUALIZER_LEN];
/*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */
/*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN];
complexi16_t eq_coeff_save[V27TER_EQUALIZER_LEN];
/*! \brief The equalizer signal buffer. */
/*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_LEN];
complexi16_t eq_buf[V27TER_EQUALIZER_LEN];
/*! \brief A measure of how much mismatch there is between the real constellation,
and the decoded symbol positions. */
float training_error;
int32_t training_error;
/*! \brief The proportional part of the carrier tracking filter. */
float carrier_track_p;
int32_t carrier_track_p;
/*! \brief The integral part of the carrier tracking filter. */
float carrier_track_i;
int32_t carrier_track_i;
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
int16_t rrc_filter[V27TER_RX_FILTER_STEPS];
#else
......
......@@ -87,7 +87,7 @@ struct v29_rx_state_s
/*! \brief A measure of how much mismatch there is between the real constellation,
and the decoded symbol positions. */
float training_error;
int32_t training_error;
/*! \brief The proportional part of the carrier tracking filter. */
int32_t carrier_track_p;
......
......@@ -126,7 +126,7 @@ SPAN_DECLARE_NONSTD(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len);
\brief Get a snapshot of the current equalizer coefficients.
\param coeffs The vector of complex coefficients.
\return The number of coefficients in the vector. */
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexi16_t **coeffs);
#else
SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs);
......
......@@ -118,7 +118,7 @@ scrambler register) cannot be trusted for the test. The receive modem,
therefore, only tests that bits starting at bit 24 are really ones.
*/
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
typedef void (*qam_report_handler_t)(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol);
#else
typedef void (*qam_report_handler_t)(void *user_data, const complexf_t *constel, const complexf_t *target, int symbol);
......
......@@ -53,13 +53,19 @@
#include "spandsp/dds.h"
#include "spandsp/power_meter.h"
#if defined(SPANDSP_USE_FIXED_POINT)
#define SPANDSP_USE_FIXED_POINTx
#endif
#include "spandsp/v17tx.h"
#include "spandsp/private/logging.h"
#include "spandsp/private/v17tx.h"
#if defined(SPANDSP_USE_FIXED_POINT)
#define SPANDSP_USE_FIXED_POINTx
#define FP_SCALE(x) ((int16_t) x)
#else
#define FP_SCALE(x) (x)
#endif
#include "v17_v32bis_tx_constellation_maps.h"
......@@ -229,6 +235,11 @@ static __inline__ complexf_t getbaud(v17_tx_state_t *s)
int i;
int bit;
int bits;
#if defined(SPANDSP_USE_FIXED_POINT)
static const complexi16_t zero = {0, 0};
#else
static const complexf_t zero = {0.0f, 0.0f};
#endif
if (s->in_training)
{
......@@ -251,11 +262,7 @@ static __inline__ complexf_t getbaud(v17_tx_state_t *s)
{
/* The shutdown sequence is 32 bauds of all 1's, then 48 bauds
of silence */
#if defined(SPANDSP_USE_FIXED_POINT)
return complex_seti16(0, 0);
#else
return complex_setf(0.0f, 0.0f);
#endif
return zero;
}
if (s->training_step == V17_TRAINING_SHUTDOWN_END)
{
......
......@@ -62,7 +62,7 @@
#include "spandsp/private/logging.h"
#include "spandsp/private/v22bis.h"
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
#define FP_SCALE FP_Q_6_10
#include "v22bis_tx_fixed_rrc.h"
#else
......@@ -248,7 +248,7 @@ static const int phase_steps[4] =
1, 0, 2, 3
};
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
const complexi16_t v22bis_constellation[16] =
#else
const complexf_t v22bis_constellation[16] =
......@@ -314,7 +314,7 @@ static __inline__ int get_scrambled_bit(v22bis_state_t *s)
}
/*- End of function --------------------------------------------------------*/
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
static complexi16_t training_get(v22bis_state_t *s)
#else
static complexf_t training_get(v22bis_state_t *s)
......@@ -417,13 +417,13 @@ static complexf_t training_get(v22bis_state_t *s)
}
/*- End of function --------------------------------------------------------*/
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
static complexi16_t getbaud(v22bis_state_t *s)
#else
static complexf_t getbaud(v22bis_state_t *s)
#endif
{
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
static const complexi16_t zero = {0, 0};
#else
static const complexf_t zero = {0.0f, 0.0f};
......@@ -464,7 +464,7 @@ static complexf_t getbaud(v22bis_state_t *s)
SPAN_DECLARE_NONSTD(int) v22bis_tx(v22bis_state_t *s, int16_t amp[], int len)
{
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
complexi16_t v;
complexi32_t x;
complexi32_t z;
......@@ -490,7 +490,7 @@ SPAN_DECLARE_NONSTD(int) v22bis_tx(v22bis_state_t *s, int16_t amp[], int len)
if (++s->tx.rrc_filter_step >= V22BIS_TX_FILTER_STEPS)
s->tx.rrc_filter_step = 0;
}
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
/* Root raised cosine pulse shaping at baseband */
x.re = vec_circular_dot_prodi16(s->tx.rrc_filter_re, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->tx.baud_phase], V22BIS_TX_FILTER_STEPS, s->tx.rrc_filter_step) >> 14;
x.im = vec_circular_dot_prodi16(s->tx.rrc_filter_im, tx_pulseshaper[TX_PULSESHAPER_COEFF_SETS - 1 - s->tx.baud_phase], V22BIS_TX_FILTER_STEPS, s->tx.rrc_filter_step) >> 14;
......@@ -551,7 +551,7 @@ SPAN_DECLARE(void) v22bis_tx_power(v22bis_state_t *s, float power)
}
sig_gain = 0.4490f*powf(10.0f, (sig_power - DBM0_MAX_POWER)/20.0f)*32768.0f/TX_PULSESHAPER_GAIN;
guard_tone_gain = powf(10.0f, (guard_tone_power - DBM0_MAX_POWER)/20.0f)*32768.0f;
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
s->tx.gain = (int16_t) sig_gain;
s->tx.guard_tone_gain = (int16_t) guard_tone_gain;
#else
......@@ -563,7 +563,7 @@ SPAN_DECLARE(void) v22bis_tx_power(v22bis_state_t *s, float power)
static int v22bis_tx_restart(v22bis_state_t *s)
{
#if defined(SPANDSP_USE_FIXED_POINTx)
#if defined(SPANDSP_USE_FIXED_POINT)
vec_zeroi16(s->tx.rrc_filter_re, sizeof(s->tx.rrc_filter_re)/sizeof(s->tx.rrc_filter_re[0]));
vec_zeroi16(s->tx.rrc_filter_im, sizeof(s->tx.rrc_filter_im)/sizeof(s->tx.rrc_filter_im[0]));
#else
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论