commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 22/39: fec: LDPC: Updating decoder to handl


From: git
Subject: [Commit-gnuradio] [gnuradio] 22/39: fec: LDPC: Updating decoder to handle parity bits either first or last.
Date: Thu, 15 Oct 2015 21:21:30 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 35bc6a3b99033e46946521960afb39a515a98cb3
Author: tracierenea <address@hidden>
Date:   Wed Feb 25 00:09:41 2015 -0600

    fec: LDPC: Updating decoder to handle parity bits either first or
    last.
    
    The convention (I hear) is that parity bits come last, at the end of
    the codeword. Richarson/Urbanke's encoding method has them first
    though. So, adding flexibility to handle either case; default is
    parity bits expected last.
---
 gr-fec/include/gnuradio/fec/fec_mtrx.h   |  4 ++++
 gr-fec/lib/fec_mtrx.cc                   |  9 ++++++++-
 gr-fec/lib/ldpc_R_U_mtrx.cc              |  5 +++++
 gr-fec/lib/ldpc_bit_flip_decoder_impl.cc | 15 +++++++++++----
 4 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/gr-fec/include/gnuradio/fec/fec_mtrx.h 
b/gr-fec/include/gnuradio/fec/fec_mtrx.h
index fceb86d..973f881 100644
--- a/gr-fec/include/gnuradio/fec/fec_mtrx.h
+++ b/gr-fec/include/gnuradio/fec/fec_mtrx.h
@@ -50,6 +50,8 @@ namespace gr {
         gsl_matrix *d_H_ptr;
         // Read the matrix from a file in alist format
         gsl_matrix *read_matrix_from_file(const std::string filename);
+        // Flag for whether or not the parity bits come first or last
+        bool d_par_bits_last;
         
       public:
         // Returns the parity check matrix H (needed by decoder)
@@ -73,6 +75,8 @@ namespace gr {
         // Find the inverse of a square matrix using modulo 2
         // operations
         gsl_matrix *calc_inverse_mod2(const gsl_matrix *) const;
+        // The decoder will need to know this
+        bool parity_bits_come_last() const;
 
         virtual ~fec_mtrx(); 
       };
diff --git a/gr-fec/lib/fec_mtrx.cc b/gr-fec/lib/fec_mtrx.cc
index 342526b..0ff60e3 100644
--- a/gr-fec/lib/fec_mtrx.cc
+++ b/gr-fec/lib/fec_mtrx.cc
@@ -34,7 +34,9 @@ namespace gr {
 
       fec_mtrx::fec_mtrx()
       {
-        // nothing for the default constructor to do
+        // Assume the convention that parity bits come last in the
+        // codeword
+        d_par_bits_last = true;
       }
 
       gsl_matrix*
@@ -291,6 +293,11 @@ namespace gr {
 
         return matrix_inverse;
       }
+      bool
+      fec_mtrx::parity_bits_come_last() const
+      {
+        return d_par_bits_last;
+      }
 
       fec_mtrx::~fec_mtrx()
       {
diff --git a/gr-fec/lib/ldpc_R_U_mtrx.cc b/gr-fec/lib/ldpc_R_U_mtrx.cc
index 2fe0605..bb7b86d 100644
--- a/gr-fec/lib/ldpc_R_U_mtrx.cc
+++ b/gr-fec/lib/ldpc_R_U_mtrx.cc
@@ -48,6 +48,11 @@ namespace gr {
         // For info about this see get_base_ptr() function
         d_base_ptr = this;
 
+        // The parity bits come first in this particular matrix
+        // format (specifically required for the Richardson Urbanke
+        // encoder)
+        d_par_bits_last = false;
+
       } // Constructor
 
       // Default constructor, should not be used
diff --git a/gr-fec/lib/ldpc_bit_flip_decoder_impl.cc 
b/gr-fec/lib/ldpc_bit_flip_decoder_impl.cc
index f7fbd3c..d99a1d5 100644
--- a/gr-fec/lib/ldpc_bit_flip_decoder_impl.cc
+++ b/gr-fec/lib/ldpc_bit_flip_decoder_impl.cc
@@ -182,10 +182,17 @@ namespace gr {
         // Extract the info word and assign to output. This will
         // happen regardless of if a valid codeword was found.
         unsigned char *out = (unsigned char*) outbuffer;
-        for (index = 0; index < d_frame_size; index++) {
-          unsigned int i = index + n - d_frame_size;
-          int value = gsl_matrix_get(x, i, 0);
-          out[index] = value;
+        if (d_mtrx->parity_bits_come_last()) {
+          for (index = 0; index < d_frame_size; index++) {
+            out[index] = gsl_matrix_get(x, index, 0);
+          }
+        }
+        else {
+          for (index = 0; index < d_frame_size; index++) {
+            unsigned int i = index + n - d_frame_size;
+            int value = gsl_matrix_get(x, i, 0);
+            out[index] = value;
+          }
         }
 
         // Free memory



reply via email to

[Prev in Thread] Current Thread [Next in Thread]