reduced sizeof tx_filter_mem, saving 100k out of 400k for FDMDV states
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 12 Jun 2012 06:12:18 +0000 (06:12 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 12 Jun 2012 06:12:18 +0000 (06:12 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@545 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/tfdmdv.m
codec2-dev/src/fdmdv.c
codec2-dev/src/fdmdv_internal.h
codec2-dev/unittest/tfdmdv.c

index 787913cf850860cff037f47ed20396730df8ade4..41e68c8855898f96d152cfe5f28cc213d6ab5551 100644 (file)
@@ -196,7 +196,7 @@ stem_sig_and_error(1, 212, real(tx_symbols_log_c(1:n/2)), real(tx_symbols_log(1:
 % tx_filter()
 
 diff = tx_baseband_log - tx_baseband_log_c;
-c=3;
+c=15;
 plot_sig_and_error(2, 211, real(tx_baseband_log_c(c,:)), real(sum(diff)), 'tx baseband real')
 plot_sig_and_error(2, 212, imag(tx_baseband_log_c(c,:)), imag(sum(diff)), 'tx baseband imag')
 
index 3526e7802a196792ab3ac7295191188a50e2e32c..1ded60f1481c7c040350de012ca37bb0717a0c81 100644 (file)
@@ -145,9 +145,12 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(void)
        f->prev_rx_symbols[c].real = 1.0;
        f->prev_rx_symbols[c].imag = 0.0;
 
-       for(k=0; k<NFILTER; k++) {
+       for(k=0; k<NSYM; k++) {
            f->tx_filter_memory[c][k].real = 0.0;
            f->tx_filter_memory[c][k].imag = 0.0;
+       }
+
+       for(k=0; k<NFILTER; k++) {
            f->rx_filter_memory[c][k].real = 0.0;
            f->rx_filter_memory[c][k].imag = 0.0;
        }
@@ -332,7 +335,7 @@ void bits_to_dqpsk_symbols(COMP tx_symbols[], COMP prev_tx_symbols[], int tx_bit
 
 \*---------------------------------------------------------------------------*/
 
-void tx_filter(COMP tx_baseband[NC+1][M], COMP tx_symbols[], COMP tx_filter_memory[NC+1][NFILTER])
+void tx_filter(COMP tx_baseband[NC+1][M], COMP tx_symbols[], COMP tx_filter_memory[NC+1][NSYM])
 {
     int     c;
     int     i,j,k;
@@ -341,9 +344,14 @@ void tx_filter(COMP tx_baseband[NC+1][M], COMP tx_symbols[], COMP tx_filter_memo
 
     gain.real = sqrt(2.0)/2.0;
     gain.imag = 0.0;
-
+    
+    /*
     for(c=0; c<NC+1; c++)
        tx_filter_memory[c][NFILTER-1] = cmult(tx_symbols[c], gain);
+    */
+    for(c=0; c<NC+1; c++)
+       tx_filter_memory[c][NSYM-1] = cmult(tx_symbols[c], gain);
+    
 
     /* 
        tx filter each symbol, generate M filtered output samples for each symbol.
@@ -356,14 +364,14 @@ void tx_filter(COMP tx_baseband[NC+1][M], COMP tx_symbols[], COMP tx_filter_memo
            /* filter real sample of symbol for carrier c */
 
            acc = 0.0;
-           for(j=M-1,k=M-i-1; j<NFILTER; j+=M,k+=M)
+           for(j=0,k=M-i-1; j<NSYM; j++,k+=M)
                acc += M * tx_filter_memory[c][j].real * gt_alpha5_root[k];
            tx_baseband[c][i].real = acc;       
 
            /* filter imag sample of symbol for carrier c */
 
            acc = 0.0;
-           for(j=M-1,k=M-i-1; j<NFILTER; j+=M,k+=M)
+           for(j=0,k=M-i-1; j<NSYM; j++,k+=M)
                acc += M * tx_filter_memory[c][j].imag * gt_alpha5_root[k];
            tx_baseband[c][i].imag = acc;
 
@@ -372,15 +380,14 @@ void tx_filter(COMP tx_baseband[NC+1][M], COMP tx_symbols[], COMP tx_filter_memo
 
     /* shift memory, inserting zeros at end */
 
-    for(i=0; i<NFILTER-M; i++)
+    for(i=0; i<NSYM-1; i++)
        for(c=0; c<NC+1; c++)
-           tx_filter_memory[c][i] = tx_filter_memory[c][i+M];
+           tx_filter_memory[c][i] = tx_filter_memory[c][i+1];
 
-    for(i=NFILTER-M; i<NFILTER; i++)
-       for(c=0; c<NC+1; c++) {
-           tx_filter_memory[c][i].real = 0.0;
-           tx_filter_memory[c][i].imag = 0.0;
-       }
+    for(c=0; c<NC+1; c++) {
+       tx_filter_memory[c][NSYM-1].real = 0.0;
+       tx_filter_memory[c][NSYM-1].imag = 0.0;
+    }
 }
 
 /*---------------------------------------------------------------------------*\
index 8c5ead6039d7cd2e611a84a0db46ef5b6e46617b..b51036e2bedd11ca8594d36aa4f292f773474eb3 100644 (file)
@@ -89,7 +89,7 @@ struct FDMDV {
 
     int  tx_pilot_bit;
     COMP prev_tx_symbols[NC+1];
-    COMP tx_filter_memory[NC+1][NFILTER];
+    COMP tx_filter_memory[NC+1][NSYM];
     COMP phase_tx[NC+1];
     COMP freq[NC+1];
  
@@ -148,7 +148,7 @@ struct FDMDV {
 \*---------------------------------------------------------------------------*/
 
 void bits_to_dqpsk_symbols(COMP tx_symbols[], COMP prev_tx_symbols[], int tx_bits[], int *pilot_bit);
-void tx_filter(COMP tx_baseband[NC+1][M], COMP tx_symbols[], COMP tx_filter_memory[NC+1][NFILTER]);
+void tx_filter(COMP tx_baseband[NC+1][M], COMP tx_symbols[], COMP tx_filter_memory[NC+1][NSYM]);
 void fdm_upconvert(COMP tx_fdm[], COMP tx_baseband[NC+1][M], COMP phase_tx[], COMP freq_tx[]);
 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);
index b33a63420763fdbec39c87e9451cd4dfb0ddfec8..50848e465d0c09a5de14481cee1534ea61398ff9 100644 (file)
@@ -102,6 +102,8 @@ int main(int argc, char *argv[])
     rx_baseband_log_col_index = 0;
     rx_filt_log_col_index = 0;
 
+    printf("sizeof FDMDV states: %d bytes\n", sizeof(struct FDMDV));
+
     for(f=0; f<FRAMES; f++) {
 
        /* --------------------------------------------------------*\