From a58b1bff15701736d03328d5fecb930e474ff801 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Wed, 13 Aug 2014 22:07:09 +0000 Subject: [PATCH] combined tx filter and up conversion to remove abou 30k of stack in tx_mod. tests out OK with tfdmdv git-svn-id: https://svn.code.sf.net/p/freetel/code@1800 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/tfdmdv.m | 8 -- codec2-dev/src/fdmdv.c | 125 +++++++++++++++++++++++++++++--- codec2-dev/src/fdmdv_internal.h | 3 + codec2-dev/unittest/tfdmdv.c | 12 +-- 4 files changed, 122 insertions(+), 26 deletions(-) diff --git a/codec2-dev/octave/tfdmdv.m b/codec2-dev/octave/tfdmdv.m index ac7186a8..e570416b 100644 --- a/codec2-dev/octave/tfdmdv.m +++ b/codec2-dev/octave/tfdmdv.m @@ -220,13 +220,6 @@ n = 28; stem_sig_and_error(1, 211, tx_bits_log_c(1:n), tx_bits_log(1:n) - tx_bits_log_c(1:n), 'tx bits', [1 n -1.5 1.5]) stem_sig_and_error(1, 212, real(tx_symbols_log_c(1:n/2)), real(tx_symbols_log(1:n/2) - tx_symbols_log_c(1:n/2)), 'tx symbols real', [1 n/2 -1.5 1.5]) -% tx_filter() - -diff = tx_baseband_log - tx_baseband_log_c; -c=1; -plot_sig_and_error(2, 211, real(tx_baseband_log_c(c,:)), real(tx_baseband_log(c,:) - tx_baseband_log_c(c,:)), 'tx baseband real') -plot_sig_and_error(2, 212, imag(tx_baseband_log_c(c,:)), imag(tx_baseband_log(c,:) - tx_baseband_log_c(c,:)), 'tx baseband imag') - % fdm_upconvert() plot_sig_and_error(3, 211, real(tx_fdm_log_c), real(tx_fdm_log - tx_fdm_log_c), 'tx fdm real') @@ -315,7 +308,6 @@ endfunction check(tx_bits_log, tx_bits_log_c, 'tx_bits'); check(tx_symbols_log, tx_symbols_log_c, 'tx_symbols'); -check(tx_baseband_log, tx_baseband_log_c, 'tx_baseband'); check(tx_fdm_log, tx_fdm_log_c, 'tx_fdm'); check(pilot_lut, pilot_lut_c, 'pilot_lut'); check(pilot_coeff, pilot_coeff_c, 'pilot_coeff'); diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index c6ea6990..2a91ed1d 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -112,7 +112,7 @@ static COMP cadd(COMP a, COMP b) static float cabsolute(COMP a) { - return sqrtf(pow(a.real, 2.0) + pow(a.imag, 2.0)); + return sqrtf(powf(a.real, 2.0) + powf(a.imag, 2.0)); } /*---------------------------------------------------------------------------*\ @@ -391,6 +391,7 @@ void bits_to_dqpsk_symbols(COMP tx_symbols[], int Nc, COMP prev_tx_symbols[], in *pilot_bit = 1; } + /*---------------------------------------------------------------------------*\ FUNCTION....: tx_filter() @@ -452,6 +453,115 @@ void tx_filter(COMP tx_baseband[NC+1][M], int Nc, COMP tx_symbols[], COMP tx_fil } } + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: tx_filter_and_upconvert() + AUTHOR......: David Rowe + DATE CREATED: 13 August 2014 + + Given Nc*NB bits construct M samples (1 symbol) of Nc+1 filtered + symbols streams. + +\*---------------------------------------------------------------------------*/ + +void tx_filter_and_upconvert(COMP tx_fdm[], int Nc, COMP tx_symbols[], + COMP tx_filter_memory[NC+1][NSYM], + COMP phase_tx[], COMP freq[], + COMP *fbb_phase, COMP fbb_rect) +{ + int c; + int i,j,k; + float acc; + COMP gain; + COMP tx_baseband; + COMP two = {2.0, 0.0}; + float mag; + + gain.real = sqrtf(2.0)/2.0; + gain.imag = 0.0; + + for(i=0; ireal /= mag; + fbb_phase->imag /= mag; + + /* shift memory, inserting zeros at end */ + + for(i=0; iNc, fdmdv->prev_tx_symbols, tx_bits, &fdmdv->tx_pilot_bit, fdmdv->old_qpsk_mapping); memcpy(fdmdv->prev_tx_symbols, tx_symbols, sizeof(COMP)*(fdmdv->Nc+1)); - PROFILE_SAMPLE_AND_LOG(tx_filter_start, mod_start, " bits_to_dqpsk_symbols"); - tx_filter(tx_baseband, fdmdv->Nc, tx_symbols, fdmdv->tx_filter_memory); - PROFILE_SAMPLE_AND_LOG(fdm_upconvert_start, tx_filter_start, " tx_filter"); - fdm_upconvert(tx_fdm, fdmdv->Nc, tx_baseband, fdmdv->phase_tx, fdmdv->freq, &fdmdv->fbb_phase_tx, fdmdv->fbb_rect); - PROFILE_SAMPLE_AND_LOG2(fdm_upconvert_start, " fdm_upconvert"); + PROFILE_SAMPLE_AND_LOG(tx_filter_and_upconvert_start, mod_start, " bits_to_dqpsk_symbols"); + tx_filter_and_upconvert(tx_fdm, fdmdv->Nc, tx_symbols, fdmdv->tx_filter_memory, + fdmdv->phase_tx, fdmdv->freq, &fdmdv->fbb_phase_tx, fdmdv->fbb_rect); *sync_bit = fdmdv->tx_pilot_bit; } diff --git a/codec2-dev/src/fdmdv_internal.h b/codec2-dev/src/fdmdv_internal.h index b66ee9ef..bf1c3a17 100644 --- a/codec2-dev/src/fdmdv_internal.h +++ b/codec2-dev/src/fdmdv_internal.h @@ -167,6 +167,9 @@ void bits_to_dqpsk_symbols(COMP tx_symbols[], int Nc, COMP prev_tx_symbols[], in void tx_filter(COMP tx_baseband[NC+1][M], int Nc, COMP tx_symbols[], COMP tx_filter_memory[NC+1][NSYM]); void fdm_upconvert(COMP tx_fdm[], int Nc, COMP tx_baseband[NC+1][M], COMP phase_tx[], COMP freq_tx[], COMP *fbb_phase, COMP fbb_rect); +void tx_filter_and_upconvert(COMP tx_fdm[], int Nc, COMP tx_symbols[], + COMP tx_filter_memory[NC+1][NSYM], + COMP phase_tx[], COMP freq[], COMP *fbb_phase, COMP fbb_rect); void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, float *filter_mem, COMP *phase, COMP *freq); void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq); float rx_est_freq_offset(struct FDMDV *f, COMP rx_fdm[], int nin); diff --git a/codec2-dev/unittest/tfdmdv.c b/codec2-dev/unittest/tfdmdv.c index 746bc940..427a1573 100644 --- a/codec2-dev/unittest/tfdmdv.c +++ b/codec2-dev/unittest/tfdmdv.c @@ -48,7 +48,6 @@ int main(int argc, char *argv[]) struct FDMDV *fdmdv; int tx_bits[FDMDV_BITS_PER_FRAME]; COMP tx_symbols[FDMDV_NC+1]; - COMP tx_baseband[NC+1][M]; COMP tx_fdm[M]; float channel[CHANNEL_BUF_SIZE]; int channel_count; @@ -68,7 +67,6 @@ int main(int argc, char *argv[]) int tx_bits_log[FDMDV_BITS_PER_FRAME*FRAMES]; COMP tx_symbols_log[(FDMDV_NC+1)*FRAMES]; - COMP tx_baseband_log[(NC+1)][M*FRAMES]; COMP tx_fdm_log[M*FRAMES]; COMP pilot_baseband1_log[NPILOTBASEBAND*FRAMES]; COMP pilot_baseband2_log[NPILOTBASEBAND*FRAMES]; @@ -115,8 +113,8 @@ int main(int argc, char *argv[]) fdmdv_get_test_bits(fdmdv, tx_bits); bits_to_dqpsk_symbols(tx_symbols, FDMDV_NC, fdmdv->prev_tx_symbols, tx_bits, &fdmdv->tx_pilot_bit, 0); memcpy(fdmdv->prev_tx_symbols, tx_symbols, sizeof(COMP)*(FDMDV_NC+1)); - tx_filter(tx_baseband, FDMDV_NC, tx_symbols, fdmdv->tx_filter_memory); - fdm_upconvert(tx_fdm, FDMDV_NC, tx_baseband, fdmdv->phase_tx, fdmdv->freq, &fdmdv->fbb_phase_tx, fdmdv->fbb_rect); + tx_filter_and_upconvert(tx_fdm, FDMDV_NC , tx_symbols, fdmdv->tx_filter_memory, + fdmdv->phase_tx, fdmdv->freq, &fdmdv->fbb_phase_tx, fdmdv->fbb_rect); /* --------------------------------------------------------*\ Channel @@ -198,9 +196,6 @@ int main(int argc, char *argv[]) memcpy(&tx_bits_log[FDMDV_BITS_PER_FRAME*f], tx_bits, sizeof(int)*FDMDV_BITS_PER_FRAME); memcpy(&tx_symbols_log[(FDMDV_NC+1)*f], tx_symbols, sizeof(COMP)*(FDMDV_NC+1)); - for(c=0; cpilot_baseband1, sizeof(COMP)*NPILOTBASEBAND); @@ -263,8 +258,7 @@ int main(int argc, char *argv[]) fprintf(fout, "# Created by tfdmdv.c\n"); octave_save_int(fout, "tx_bits_log_c", tx_bits_log, 1, FDMDV_BITS_PER_FRAME*FRAMES); octave_save_complex(fout, "tx_symbols_log_c", tx_symbols_log, 1, (FDMDV_NC+1)*FRAMES, (FDMDV_NC+1)*FRAMES); - octave_save_complex(fout, "tx_baseband_log_c", (COMP*)tx_baseband_log, (FDMDV_NC+1), M*FRAMES, M*FRAMES); - octave_save_complex(fout, "tx_fdm_log_c", (COMP*)tx_fdm_log, 1, M*FRAMES, M*FRAMES); +octave_save_complex(fout, "tx_fdm_log_c", (COMP*)tx_fdm_log, 1, M*FRAMES, M*FRAMES); octave_save_complex(fout, "pilot_lut_c", (COMP*)fdmdv->pilot_lut, 1, NPILOT_LUT, NPILOT_LUT); octave_save_complex(fout, "pilot_baseband1_log_c", pilot_baseband1_log, 1, NPILOTBASEBAND*FRAMES, NPILOTBASEBAND*FRAMES); octave_save_complex(fout, "pilot_baseband2_log_c", pilot_baseband2_log, 1, NPILOTBASEBAND*FRAMES, NPILOTBASEBAND*FRAMES); -- 2.25.1