non trival UW, but still occasional false syncs, and can be slow to sync
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 17 Apr 2018 07:35:58 +0000 (07:35 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 17 Apr 2018 07:35:58 +0000 (07:35 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3494 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/ofdm_ldpc_rx.m
codec2-dev/octave/ofdm_ldpc_tx.m
codec2-dev/octave/ofdm_lib.m

index 3c5fa44bced5bbab79b1ce95f1b91be83e7a2044..00d909e18f753e3c5426d11b99213155941bffe9 100644 (file)
@@ -184,7 +184,7 @@ function ofdm_ldpc_rx(filename, interleave_frames = 1, error_pattern_filename)
         end
         for ff=1:interleave_frames
           st = (ff-1)*Ncodedbitsperframe+1; en = st+Ncodedbitsperframe-1;
-          errors = xor(tx_bits_raw(st:en), rx_bits_raw(st:en));
+          errors = xor(acodeword, rx_bits_raw(st:en));
           Nerrs = sum(errors);
           Nerrs_log = [Nerrs_log Nerrs];
           Nerrs_raw += Nerrs;
index 098518a5dd269ce09f40dcb7ad0c925749c38391..4dd5eb61c184a8d886aebd0006c9a03810f64bd8 100644 (file)
@@ -82,8 +82,8 @@ function ofdm_ldpc_tx(filename, interleave_frames = 1, Nsec, EbNodB=100, channel
   tx_symbols = gp_interleave(tx_symbols);
   
   % generate UW and txt symbols to prepend to every frame after LDPC encoding and interleaving
-  
-  tx_uw_tx_bits = [zeros(1,Nuwbits) zeros(1,Ntxtbits)];
+  tx_uw_tx_bits = [1 0 0 1 0 1 0 0 1 0 zeros(1,Ntxtbits)];
   tx_uw_tx_symbols = [];
   for b=1:2:length(tx_uw_tx_bits)
     tx_uw_tx_symbols = [tx_uw_tx_symbols qpsk_mod(tx_uw_tx_bits(b:b+1))];
index 4a7699d6d733ddef15e974ef79b085e2e367984c..8a0ad22c7770dbf6aabbc745e1248ed7c90cab99 100644 (file)
@@ -515,7 +515,7 @@ endfunction
 % generate a test frame of ldpc encoded bits, used for raw and
 % coded BER testing.  Includes UW and txt files
 
-function [tx_bits payload_data_bits] = create_ldpc_test_frame
+function [tx_bits payload_data_bits codeword] = create_ldpc_test_frame
   Ts = 0.018; Tcp = 0.002; Rs = 1/Ts; bps = 2; Nc = 17; Ns = 8;
   states = ofdm_init(bps, Rs, Tcp, Ns, Nc);
   ofdm_load_const;
@@ -567,7 +567,7 @@ endfunction
 %
 
 function test_bits_ofdm_file
-  [test_bits_ofdm payload_data_bits] = create_ldpc_test_frame;
+  [test_bits_ofdm payload_data_bits codeword] = create_ldpc_test_frame;
   printf("%d test bits\n", length(test_bits_ofdm));
   
   f=fopen("../src/test_bits_ofdm.h","wt");
@@ -583,6 +583,13 @@ function test_bits_ofdm_file
     fprintf(f,"  %d,\n",payload_data_bits(m));
   endfor
   fprintf(f,"  %d\n};\n",payload_data_bits(end));
+
+  fprintf(f,"\nconst int test_codeword[]={\n");
+  for m=1:length(codeword)-1
+    fprintf(f,"  %d,\n",codeword(m));
+  endfor
+  fprintf(f,"  %d\n};\n",codeword(end));
+
   fclose(f);
 
 endfunction
@@ -637,7 +644,9 @@ function states = sync_state_machine(states, rx_uw)
     % freq offset est may be too far out, and has aliases every 1/Ts, so
     % we use a Unique Word to get a really solid indication of sync.
 
-    states.uw_errors = sum(rx_uw);
+    tx_uw = [1 0 0 1 0 1 0 0 1 0];
+
+    states.uw_errors = sum(xor(tx_uw,rx_uw));
     if (states.uw_errors > uw_thresh)
       states.sync_counter++;
       if states.sync_counter == sync_counter_thresh