From: drowe67 Date: Wed, 18 Apr 2018 21:10:34 +0000 (+0000) Subject: refactored UW insertion X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=3839c3c669f046ae3c6d93a355aff24e3252e1c4;p=freetel-svn-tracking.git refactored UW insertion git-svn-id: https://svn.code.sf.net/p/freetel/code@3500 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/README_ofdm.txt b/codec2-dev/README_ofdm.txt index 3f90b6d5..da02ee44 100644 --- a/codec2-dev/README_ofdm.txt +++ b/codec2-dev/README_ofdm.txt @@ -37,9 +37,9 @@ Built as part of codec2-dev, see README for build instructions. build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | play -t raw -r 8000 -s -2 - -2. Generate 10 seconds of test frame bits, modulate, demodulate, count errors: +2. Generate 10 seconds of uncoded test frame bits, modulate, demodulate, count errors: - build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | ./ofdm_demod -t - /dev/null + build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | ./ofdm_demod - /dev/null -t (TODO write ofdm_demod_c.m) Use Octave to look at plots of C modem operation: @@ -74,14 +74,14 @@ Built as part of codec2-dev, see README for build instructions. octave:6> ofdm_ldpc_tx('ofdm_test.raw',4,60,3) octave:7> ofdm_ldpc_rx('ofdm_test.raw',4) - C demodulator/LDCP decoder: + C demodulator/LDPC decoder: build_linux/src$ ./ofdm_demod ../../octave/ofdm_test.raw /dev/null -v -t --ldpc --interleave 4 Acceptance Tests ---------------- -The rate 1/2 LPDC code can correct up to about 10% raw BER, so a good +The rate 1/2 LDPC code can correct up to about 10% raw BER, so a good test is to run the modem at Eb/No operating points that produce just less that BER=0.1 diff --git a/codec2-dev/src/ofdm.c b/codec2-dev/src/ofdm.c index 12f13dc3..6ee6037a 100644 --- a/codec2-dev/src/ofdm.c +++ b/codec2-dev/src/ofdm.c @@ -82,6 +82,8 @@ static const char pilotvalues[] = { 1 }; +static const int tx_uw[] = {1,0,0,1,0,1,0,0,1,0}; + /* Functions */ /* Gray coded QPSK modulation function */ @@ -384,7 +386,10 @@ struct OFDM *ofdm_create(const struct OFDM_CONFIG *config) { ofdm->foff_running = 0.0 + I*0.0; /* sync state machine */ - + + for(i=0; itx_uw[i] = tx_uw[i]; + } strcpy(ofdm->sync_state,"search"); strcpy(ofdm->last_sync_state,"search"); ofdm->uw_errors = 0; @@ -1002,9 +1007,8 @@ void ofdm_sync_state_machine(struct OFDM *ofdm, int *rx_uw) { we use a Unique Word to get a really solid indication of sync. */ ofdm->uw_errors = 0; - int tx_uw[] = {1,0,0,1,0,1,0,0,1,0}; for (i=0; iuw_errors += tx_uw[i] ^ rx_uw[i]; + ofdm->uw_errors += ofdm->tx_uw[i] ^ rx_uw[i]; } /* during trial sync we don't tolerate errors so much, we look diff --git a/codec2-dev/src/ofdm_demod.c b/codec2-dev/src/ofdm_demod.c index ad651c4a..66aac11a 100644 --- a/codec2-dev/src/ofdm_demod.c +++ b/codec2-dev/src/ofdm_demod.c @@ -121,15 +121,16 @@ int main(int argc, char *argv[]) if (argc < 3) { fprintf(stderr, "\n"); - printf("usage: %s InputModemRawFile OutputFile [-o OctaveLogFile] [--llr] [-v VerboseLevel]\n", argv[0]); + printf("usage: %s InputModemRawFile OutputFile [-o OctaveLogFile] [--llr] [--ldpc] [--interleave depth] [-v]\n", argv[0]); fprintf(stderr, "\n"); - fprintf(stderr, " Default output file format is one byte per bit hard decision\n"); - fprintf(stderr, " --llr LLR output, one double per bit, %d doubles/frame\n", CODED_BITSPERFRAME); - fprintf(stderr, " -t Receive test frames and count errors\n"); - fprintf(stderr, " --ldpc Run (224,112) LDPC decoder. This forces 112, one char/bit output values\n" - " per frame. In testframe mode (-t) raw and coded errors will be counted\n"); - fprintf(stderr, " -v Verbose info the stderr\n"); - fprintf(stderr, " -o Octave log file for testing\n"); + fprintf(stderr, " Default output file format is one byte per bit hard decision\n"); + fprintf(stderr, " --llr LLR output, one double per bit, %d doubles/frame\n", CODED_BITSPERFRAME); + fprintf(stderr, " -t Receive test frames and count errors\n"); + fprintf(stderr, " --ldpc Run (224,112) LDPC decoder. This forces 112, one char/bit output values\n" + " per frame. In testframe mode (-t) raw and coded errors will be counted\n"); + fprintf(stderr, " --interleave Interleaver for LDPC frames, e.g. 1,2,4,8,16, default is 1\n"); + fprintf(stderr, " -v Verbose info the stderr\n"); + fprintf(stderr, " -o Octave log file for testing\n"); fprintf(stderr, "\n"); exit(1); } diff --git a/codec2-dev/src/ofdm_get_test_bits.c b/codec2-dev/src/ofdm_get_test_bits.c index 2ee037d1..89780b91 100644 --- a/codec2-dev/src/ofdm_get_test_bits.c +++ b/codec2-dev/src/ofdm_get_test_bits.c @@ -8,7 +8,6 @@ \*---------------------------------------------------------------------------*/ - /* Copyright (C) 2018 David Rowe diff --git a/codec2-dev/src/ofdm_internal.h b/codec2-dev/src/ofdm_internal.h index 1958b4e1..1586e63f 100644 --- a/codec2-dev/src/ofdm_internal.h +++ b/codec2-dev/src/ofdm_internal.h @@ -127,6 +127,7 @@ struct OFDM { /* modem sync state machine */ + int tx_uw[OFDM_NUWBITS]; char sync_state[OFDM_STATE_STR]; char last_sync_state[OFDM_STATE_STR]; int uw_errors; diff --git a/codec2-dev/src/test_bits_ofdm.h b/codec2-dev/src/test_bits_ofdm.h index 17b55b38..423626e5 100644 --- a/codec2-dev/src/test_bits_ofdm.h +++ b/codec2-dev/src/test_bits_ofdm.h @@ -1,15 +1,15 @@ /* Generated by test_bits_ofdm_file() Octave function */ const int test_bits_ofdm[]={ + 1, 0, 0, + 1, 0, + 1, 0, 0, - 0, - 0, - 0, - 0, + 1, 0, 0, 0,