refactored UW insertion
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 18 Apr 2018 21:09:21 +0000 (21:09 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 18 Apr 2018 21:09:21 +0000 (21:09 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3499 01035d8c-6547-0410-b346-abe4f91aad63

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

index 4dd5eb61c184a8d886aebd0006c9a03810f64bd8..32b6a8bde17bbf27abdb303ce73c16a576e7feb8 100644 (file)
@@ -83,7 +83,7 @@ function ofdm_ldpc_tx(filename, interleave_frames = 1, Nsec, EbNodB=100, channel
   
   % generate UW and txt symbols to prepend to every frame after LDPC encoding and interleaving
  
-  tx_uw_tx_bits = [1 0 0 1 0 1 0 0 1 0 zeros(1,Ntxtbits)];
+  tx_uw_tx_bits = [tx_uw 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 89587ab3b9d68612eb47286c307521df59ebe5b4..e7b56f1298fcaa351a35cd48716a3b19e39f962a 100644 (file)
@@ -138,6 +138,8 @@ function states = ofdm_init(bps, Rs, Tcp, Ns, Nc)
   states.Nsamperframe =  (states.Nrowsperframe+1)*(states.M+states.Ncp);
   states.Ntxtbits = 4;   % reserve 4 bits/frame for auxillary text information
   states.Nuwbits  = (Ns-1)*bps - states.Ntxtbits;
+  states.tx_uw = [1 0 0 1 0 1 0 0 1 0];
+  assert(length(states.tx_uw) == states.Nuwbits);
 
   % generate same pilots each time
 
@@ -194,7 +196,7 @@ function states = ofdm_init(bps, Rs, Tcp, Ns, Nc)
   % printf("timing_norm: %f\n", states.timing_norm)
 
   % sync state machine
-  
+
   states.sync_state = states.last_sync_state = 'search';
   states.uw_errors = 0;
   states.sync_counter = 0;
@@ -554,7 +556,7 @@ function [tx_bits payload_data_bits codeword] = create_ldpc_test_frame
 
   % insert UW and txt bits
   
-  tx_bits = [zeros(1,Nuwbits) zeros(1,Ntxtbits) codeword_raw];
+  tx_bits = [tx_uw zeros(1,Ntxtbits) codeword_raw];
   assert(Nbitsperframe == length(tx_bits));
 
 endfunction
@@ -644,8 +646,6 @@ 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.
 
-    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++;
index e4b87746606a2920aafb0632c906540bcefc051f..dd6342416bd6146ee51d8078668b91e99683c00d 100644 (file)
@@ -15,6 +15,7 @@ Nsamperframe = states.Nsamperframe;
 timing_mx_thresh = 0.3;
 Nuwbits = states.Nuwbits;
 Ntxtbits = states.Ntxtbits;
+tx_uw =  states.tx_uw;
 
 W = states.W;
 w = states.w;