Add foff_est_hz to unittest
authorokcsampson <okcsampson@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 18 Jun 2017 12:28:20 +0000 (12:28 +0000)
committerokcsampson <okcsampson@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 18 Jun 2017 12:28:20 +0000 (12:28 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3211 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/tofdm.m
codec2-dev/unittest/tofdm.c

index 8b870f3711a2c551ccffb46fc87a27b3eed404ab..3aec69d43fb8cfed28d5729db9bffc27b451397c 100644 (file)
@@ -41,10 +41,10 @@ nin = Nsamperframe+2*(M+Ncp);
 states.rxbuf(Nrxbuf-nin+1:Nrxbuf) = rx(prx:nin);
 prx += nin;
 
-rxbuf_log = []; rxbuf_in_log = []; rx_sym_log = [];
+rxbuf_log = []; rxbuf_in_log = []; rx_sym_log = []; foff_hz_log = [];
 
 states.timing_en = 0;
-states.foff_est_en = 0;
+states.foff_est_en = 1;
 states.phase_est_en = 0;
 
 for f=1:Nframes
@@ -69,26 +69,31 @@ for f=1:Nframes
   rxbuf_in_log = [rxbuf_in_log rxbuf_in];
   rxbuf_log = [rxbuf_log states.rxbuf];
   rx_sym_log = [rx_sym_log; states.rx_sym];
+  foff_hz_log = [foff_hz_log; states.foff_est_hz];
 end
 
 % ---------------------------------------------------------------------
 % Run C version and plot Octave and C states and differences 
 % ---------------------------------------------------------------------
 
-system('../build_linux/unittest/tofdm');
+system('/home/ssampson/testing/tofdm');
 load tofdm_out.txt;
 
 stem_sig_and_error(1, 111, tx_bits_log_c, tx_bits_log - tx_bits_log_c, 'tx bits', [1 length(tx_bits_log) -1.5 1.5])
+
 stem_sig_and_error(2, 211, real(tx_log_c), real(tx_log - tx_log_c), 'tx re', [1 length(tx_log_c) -0.1 0.1])
 stem_sig_and_error(2, 212, imag(tx_log_c), imag(tx_log - tx_log_c), 'tx im', [1 length(tx_log_c) -0.1 0.1])
+
 stem_sig_and_error(3, 211, real(rxbuf_in_log_c), real(rxbuf_in_log - rxbuf_in_log_c), 'rxbuf in re', [1 length(rxbuf_in_log_c) -0.1 0.1])
 stem_sig_and_error(3, 212, imag(rxbuf_in_log_c), imag(rxbuf_in_log - rxbuf_in_log_c), 'rxbuf in im', [1 length(rxbuf_in_log_c) -0.1 0.1])
+
 stem_sig_and_error(4, 211, real(rxbuf_log_c), real(rxbuf_log - rxbuf_log_c), 'rxbuf re', [1 length(rxbuf_log_c) -0.1 0.1])
 stem_sig_and_error(4, 212, imag(rxbuf_log_c), imag(rxbuf_log - rxbuf_log_c), 'rxbuf im', [1 length(rxbuf_log_c) -0.1 0.1])
 
-r=1;
-stem_sig_and_error(4, 211, real(rx_sym_log_c(r,:)), real(rx_sym_log(r,:) - rx_sym_log_c(r,:)), 'rx sym re', [1 length(rx_sym_log_c) -1.5 1.5])
-stem_sig_and_error(4, 212, imag(rx_sym_log_c(r,:)), imag(rx_sym_log(r,:) - rx_sym_log_c(r,:)), 'rx sym im', [1 length(rx_sym_log_c) -1.5 1.5])
+stem_sig_and_error(5, 211, real(rx_sym_log_c), real(rx_sym_log - rx_sym_log_c), 'rx sym re', [1 length(rx_sym_log_c) -1.5 1.5])
+stem_sig_and_error(5, 212, imag(rx_sym_log_c), imag(rx_sym_log - rx_sym_log_c), 'rx sym im', [1 length(rx_sym_log_c) -1.5 1.5])
+
+stem_sig_and_error(6, 111, foff_hz_log_c, (foff_hz_log - foff_hz_log_c), 'foff hz', [1 length(foff_hz_log_c) -1.5 1.5])
 
 % Run through checklist -----------------------------
 
@@ -98,3 +103,4 @@ check(tx_log, tx_log_c, 'tx');
 check(rxbuf_in_log, rxbuf_in_log_c, 'rxbuf in');
 check(rxbuf_log, rxbuf_log_c, 'rxbuf');
 check(rx_sym_log, rx_sym_log_c, 'rx_sym');
+check(foff_hz_log, foff_hz_log_c, 'foff_est_hz');
index 59134dc8266f8bc5944972ece5557bd869e680d3..c7647ed8d4164c54c198417c26e6f7fab7fc518b 100644 (file)
@@ -58,6 +58,7 @@ int main(int argc, char *argv[])
     COMP           rxbuf_in_log[max_samples_per_frame*NFRAMES];
     COMP           rxbuf_log[OFDM_RXBUF*NFRAMES];
     COMP           rx_sym_log[(OFDM_NS + 3)*NFRAMES][OFDM_NC + 2];
+    float          foff_hz_log[NFRAMES];
 
     FILE          *fout;
     int            f,i,j;
@@ -107,7 +108,7 @@ int main(int argc, char *argv[])
     /* disable estimators for initial testing */
 
     ofdm_set_timing_enable(ofdm, false);
-    ofdm_set_foff_est_enable(ofdm, false);
+    ofdm_set_foff_est_enable(ofdm, true);
     ofdm_set_phase_est_enable(ofdm, false);
 
     for(f=0; f<NFRAMES; f++) {
@@ -159,6 +160,8 @@ int main(int argc, char *argv[])
                 rx_sym_log[(OFDM_NS + 3)*f+i][j].imag = cimagf(ofdm->rx_sym[i][j]);
             }
         }
+
+        foff_hz_log[f] = ofdm->foff_est_hz;
     }
 
     /*---------------------------------------------------------*\
@@ -175,6 +178,7 @@ int main(int argc, char *argv[])
     octave_save_complex(fout, "rxbuf_in_log_c", (COMP*)rxbuf_in_log, 1, nin_tot, nin_tot);
     octave_save_complex(fout, "rxbuf_log_c", (COMP*)rxbuf_log, 1, OFDM_RXBUF*NFRAMES,  OFDM_RXBUF*NFRAMES);
     octave_save_complex(fout, "rx_sym_log_c", (COMP*)rx_sym_log, (OFDM_NS + 3)*NFRAMES, OFDM_NC + 2, OFDM_NC + 2);
+    octave_save_float(fout, "foff_hz_log_c", foff_hz_log, 1, NFRAMES, 1);
     fclose(fout);
 
     ofdm_destroy(ofdm);