From 7a9c559221a56a06618f251262b3837fd6f38e2a Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 17 Apr 2018 07:35:58 +0000 Subject: [PATCH] non trival UW, but still occasional false syncs, and can be slow to sync git-svn-id: https://svn.code.sf.net/p/freetel/code@3494 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/ofdm_ldpc_rx.m | 2 +- codec2-dev/octave/ofdm_ldpc_tx.m | 4 ++-- codec2-dev/octave/ofdm_lib.m | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/codec2-dev/octave/ofdm_ldpc_rx.m b/codec2-dev/octave/ofdm_ldpc_rx.m index 3c5fa44b..00d909e1 100644 --- a/codec2-dev/octave/ofdm_ldpc_rx.m +++ b/codec2-dev/octave/ofdm_ldpc_rx.m @@ -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; diff --git a/codec2-dev/octave/ofdm_ldpc_tx.m b/codec2-dev/octave/ofdm_ldpc_tx.m index 098518a5..4dd5eb61 100644 --- a/codec2-dev/octave/ofdm_ldpc_tx.m +++ b/codec2-dev/octave/ofdm_ldpc_tx.m @@ -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))]; diff --git a/codec2-dev/octave/ofdm_lib.m b/codec2-dev/octave/ofdm_lib.m index 4a7699d6..8a0ad22c 100644 --- a/codec2-dev/octave/ofdm_lib.m +++ b/codec2-dev/octave/ofdm_lib.m @@ -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 -- 2.25.1