[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 16/25: fec: polar: whitespace fixes/tabs to
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 16/25: fec: polar: whitespace fixes/tabs to go along with namespace change from last commit. |
Date: |
Wed, 23 Sep 2015 14:51:38 +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 9df0fda8d2c29874d581dbaf6670558a84d9328b
Author: Tom Rondeau <address@hidden>
Date: Tue Sep 22 15:12:32 2015 -0400
fec: polar: whitespace fixes/tabs to go along with namespace change from
last commit.
---
gr-fec/include/gnuradio/fec/polar_common.h | 102 +++----
gr-fec/include/gnuradio/fec/polar_decoder_common.h | 100 +++---
gr-fec/include/gnuradio/fec/polar_decoder_sc.h | 76 ++---
.../include/gnuradio/fec/polar_decoder_sc_list.h | 96 +++---
gr-fec/include/gnuradio/fec/polar_encoder.h | 140 ++++-----
gr-fec/lib/polar_common.cc | 160 +++++-----
gr-fec/lib/polar_decoder_common.cc | 272 ++++++++---------
gr-fec/lib/polar_decoder_sc.cc | 96 +++---
gr-fec/lib/polar_decoder_sc_list.cc | 138 ++++-----
gr-fec/lib/polar_encoder.cc | 338 ++++++++++-----------
gr-fec/lib/scl_list.cc | 272 ++++++++---------
gr-fec/lib/scl_list.h | 90 +++---
12 files changed, 940 insertions(+), 940 deletions(-)
diff --git a/gr-fec/include/gnuradio/fec/polar_common.h
b/gr-fec/include/gnuradio/fec/polar_common.h
index 3ee7815..7ef3e59 100644
--- a/gr-fec/include/gnuradio/fec/polar_common.h
+++ b/gr-fec/include/gnuradio/fec/polar_common.h
@@ -39,65 +39,65 @@ namespace gr {
namespace fec {
namespace code {
- /*!
- * \brief POLAR code common operations and attributes
- * \ingroup error_coding_blk
- *
- * \details
- * Polar codes are based on this paper by Erdal Arikan "Channel
- * Polarization: A Method for Contructing Capacity-Achieving Codes
- * for Symmetric Binary-Input Memoryless Channels", 2009 block
- * holds common information for encoders and decoders. All polar
- * encoder/decoders inherit from polar_common.
- *
- * class holds common info. It is common to all encoders and decoders.
- */
- class FEC_API polar_common
- {
- public:
/*!
- * \param block_size codeword size. MUST be a power of 2.
- * \param num_info_bits represents the number of information
- * bits in a block. Also called frame_size. <= block_size
- * \param frozen_bit_positions is an integer vector which
- * defines the position of all frozen bits in a block.
- * Its size MUST be equal to block_size - num_info_bits.
- * Also it must be sorted and every position must only
- * occur once.
- * \param frozen_bit_values holds an unpacked byte for every
- * frozen bit position. It defines if a frozen bit is
- * fixed to '0' or '1'. Defaults to all ZERO.
+ * \brief POLAR code common operations and attributes
+ * \ingroup error_coding_blk
+ *
+ * \details
+ * Polar codes are based on this paper by Erdal Arikan "Channel
+ * Polarization: A Method for Contructing Capacity-Achieving Codes
+ * for Symmetric Binary-Input Memoryless Channels", 2009 block
+ * holds common information for encoders and decoders. All polar
+ * encoder/decoders inherit from polar_common.
+ *
+ * class holds common info. It is common to all encoders and decoders.
*/
- polar_common(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values);
- ~polar_common();
+ class FEC_API polar_common
+ {
+ public:
+ /*!
+ * \param block_size codeword size. MUST be a power of 2.
+ * \param num_info_bits represents the number of information
+ * bits in a block. Also called frame_size. <= block_size
+ * \param frozen_bit_positions is an integer vector which
+ * defines the position of all frozen bits in a block.
+ * Its size MUST be equal to block_size - num_info_bits.
+ * Also it must be sorted and every position must only
+ * occur once.
+ * \param frozen_bit_values holds an unpacked byte for every
+ * frozen bit position. It defines if a frozen bit is
+ * fixed to '0' or '1'. Defaults to all ZERO.
+ */
+ polar_common(int block_size, int num_info_bits,
+ std::vector<int> frozen_bit_positions,
+ std::vector<char> frozen_bit_values);
+ ~polar_common();
- protected:
- const int block_size()const {return d_block_size;};
- const int block_power()const {return d_block_power;};
- const int num_info_bits() const {return d_num_info_bits;};
+ protected:
+ const int block_size()const {return d_block_size;};
+ const int block_power()const {return d_block_power;};
+ const int num_info_bits() const {return d_num_info_bits;};
- // helper functions
- long bit_reverse(long value, int active_bits) const;
- void print_packed_bit_array(const unsigned char* printed_array,
- const int num_bytes) const;
- void print_unpacked_bit_array(const unsigned char* bits,
- const unsigned int num_bytes) const;
+ // helper functions
+ long bit_reverse(long value, int active_bits) const;
+ void print_packed_bit_array(const unsigned char* printed_array,
+ const int num_bytes) const;
+ void print_unpacked_bit_array(const unsigned char* bits,
+ const unsigned int num_bytes) const;
- std::vector<int> d_frozen_bit_positions;
- std::vector<char> d_frozen_bit_values;
- std::vector<int> d_info_bit_positions;
+ std::vector<int> d_frozen_bit_positions;
+ std::vector<char> d_frozen_bit_values;
+ std::vector<int> d_info_bit_positions;
- private:
- int d_block_size; // depending on paper called 'N' or 'm'
- int d_block_power;
- int d_num_info_bits; // mostly abbreviated by 'K'
+ private:
+ int d_block_size; // depending on paper called 'N' or 'm'
+ int d_block_power;
+ int d_num_info_bits; // mostly abbreviated by 'K'
- void initialize_info_bit_position_vector();
+ void initialize_info_bit_position_vector();
- gr::blocks::kernel::unpack_k_bits *d_unpacker; // convenience for
'print_packed_bit_array' function.
- };
+ gr::blocks::kernel::unpack_k_bits *d_unpacker; // convenience for
'print_packed_bit_array' function.
+ };
} //namespace code
} // namespace fec
diff --git a/gr-fec/include/gnuradio/fec/polar_decoder_common.h
b/gr-fec/include/gnuradio/fec/polar_decoder_common.h
index 7a18ba8..b0ecb85 100644
--- a/gr-fec/include/gnuradio/fec/polar_decoder_common.h
+++ b/gr-fec/include/gnuradio/fec/polar_decoder_common.h
@@ -32,66 +32,66 @@ namespace gr {
namespace fec {
namespace code {
- /*!
- * \brief Class holds common methods and attributes for different
- * decoder implementations
- */
- class FEC_API polar_decoder_common : public generic_decoder, public
polar_common
- {
- public:
/*!
- *
- * \param block_size codeword size. MUST be a power of 2.
- * \param num_info_bits represents the number of information bits
- * in a block. Also called frame_size. <= block_size
- * \param frozen_bit_positions is an integer vector which defines
- * the position of all frozen bits in a block. Its size
- * MUST be equal to block_size - num_info_bits. Also it
- * must be sorted and every position must only occur once.
- * \param frozen_bit_values holds an unpacked byte for every
- * frozen bit position. It defines if a frozen bit is
- * fixed to '0' or '1'. Defaults to all ZERO.
+ * \brief Class holds common methods and attributes for different
+ * decoder implementations
*/
- polar_decoder_common(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values);
- ~polar_decoder_common();
+ class FEC_API polar_decoder_common : public generic_decoder, public
polar_common
+ {
+ public:
+ /*!
+ *
+ * \param block_size codeword size. MUST be a power of 2.
+ * \param num_info_bits represents the number of information bits
+ * in a block. Also called frame_size. <= block_size
+ * \param frozen_bit_positions is an integer vector which defines
+ * the position of all frozen bits in a block. Its size
+ * MUST be equal to block_size - num_info_bits. Also it
+ * must be sorted and every position must only occur once.
+ * \param frozen_bit_values holds an unpacked byte for every
+ * frozen bit position. It defines if a frozen bit is
+ * fixed to '0' or '1'. Defaults to all ZERO.
+ */
+ polar_decoder_common(int block_size, int num_info_bits,
+ std::vector<int> frozen_bit_positions,
+ std::vector<char> frozen_bit_values);
+ ~polar_decoder_common();
- // FECAPI
- double rate(){return (1.0 * get_output_size() / get_input_size());};
- int get_input_size(){return block_size();};
- int get_output_size(){return num_info_bits();};
- bool set_frame_size(unsigned int frame_size){return false;};
+ // FECAPI
+ double rate(){return (1.0 * get_output_size() / get_input_size());};
+ int get_input_size(){return block_size();};
+ int get_output_size(){return num_info_bits();};
+ bool set_frame_size(unsigned int frame_size){return false;};
- private:
- static const float D_LLR_FACTOR = -2.19722458f;
- unsigned int d_frozen_bit_counter;
+ private:
+ static const float D_LLR_FACTOR = -2.19722458f;
+ unsigned int d_frozen_bit_counter;
- protected:
- // calculate LLRs for stage
- float llr_odd(const float la, const float lb) const;
- float llr_even(const float la, const float lb, const unsigned char f)
const;
- unsigned char llr_bit_decision(const float llr) const {return (llr <
0.0f) ? 1 : 0;};
+ protected:
+ // calculate LLRs for stage
+ float llr_odd(const float la, const float lb) const;
+ float llr_even(const float la, const float lb, const unsigned char f)
const;
+ unsigned char llr_bit_decision(const float llr) const {return (llr <
0.0f) ? 1 : 0;};
- // control retrieval of frozen bits.
- const bool is_frozen_bit(const int u_num) const;
- const unsigned char next_frozen_bit();
+ // control retrieval of frozen bits.
+ const bool is_frozen_bit(const int u_num) const;
+ const unsigned char next_frozen_bit();
- // preparation for decoding
- void initialize_decoder(unsigned char* u, float* llrs, const float*
input);
+ // preparation for decoding
+ void initialize_decoder(unsigned char* u, float* llrs, const float*
input);
- // basic algorithm methods
- void butterfly(float* llrs, unsigned char* u, const int stage, const int
u_num, const int row);
- void butterfly_volk(float* llrs, unsigned char* u, const int stage,
const int u_num, const int row);
- void butterfly_generic(float* llrs, unsigned char* u, const int stage,
const int u_num, const int row);
- void even_u_values(unsigned char* u_even, const unsigned char* u, const
int u_num);
- void odd_xor_even_values(unsigned char* u_xor, const unsigned char* u,
const int u_num);
- void extract_info_bits(unsigned char* output, const unsigned char*
input) const;
+ // basic algorithm methods
+ void butterfly(float* llrs, unsigned char* u, const int stage, const
int u_num, const int row);
+ void butterfly_volk(float* llrs, unsigned char* u, const int stage,
const int u_num, const int row);
+ void butterfly_generic(float* llrs, unsigned char* u, const int stage,
const int u_num, const int row);
+ void even_u_values(unsigned char* u_even, const unsigned char* u,
const int u_num);
+ void odd_xor_even_values(unsigned char* u_xor, const unsigned char* u,
const int u_num);
+ void extract_info_bits(unsigned char* output, const unsigned char*
input) const;
- // helper functions.
- void print_pretty_llr_vector(const float* llr_vec) const;
+ // helper functions.
+ void print_pretty_llr_vector(const float* llr_vec) const;
- };
+ };
} // namespace code
} // namespace fec
diff --git a/gr-fec/include/gnuradio/fec/polar_decoder_sc.h
b/gr-fec/include/gnuradio/fec/polar_decoder_sc.h
index 295e930..3563a06 100644
--- a/gr-fec/include/gnuradio/fec/polar_decoder_sc.h
+++ b/gr-fec/include/gnuradio/fec/polar_decoder_sc.h
@@ -32,50 +32,50 @@ namespace gr {
namespace fec {
namespace code {
- /*!
- * \brief Standard successive cancellation (SC) decoder for POLAR codes
- *
- * \details
- * It expects float input with bits mapped 1 --> 1, 0 --> -1
- * Or: f = 2.0 * bit - 1.0
- *
- */
- class FEC_API polar_decoder_sc : public polar_decoder_common
- {
- public:
-
/*!
- * \param block_size codeword size. MUST be a power of 2.
- * \param num_info_bits represents the number of information
- * bits in a block. Also called frame_size. <= block_size
- * \param frozen_bit_positions is an integer vector which
- * defines the position of all frozen bits in a block.
- * Its size MUST be equal to block_size - num_info_bits.
- * Also it must be sorted and every position must only
- * occur once.
- * \param frozen_bit_values holds an unpacked byte for every
- * frozen bit position. It defines if a frozen bit is
- * fixed to '0' or '1'. Defaults to all ZERO.
+ * \brief Standard successive cancellation (SC) decoder for POLAR codes
+ *
+ * \details
+ * It expects float input with bits mapped 1 --> 1, 0 --> -1
+ * Or: f = 2.0 * bit - 1.0
+ *
*/
- static generic_decoder::sptr make(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values);
- ~polar_decoder_sc();
+ class FEC_API polar_decoder_sc : public polar_decoder_common
+ {
+ public:
+
+ /*!
+ * \param block_size codeword size. MUST be a power of 2.
+ * \param num_info_bits represents the number of information
+ * bits in a block. Also called frame_size. <= block_size
+ * \param frozen_bit_positions is an integer vector which
+ * defines the position of all frozen bits in a block.
+ * Its size MUST be equal to block_size - num_info_bits.
+ * Also it must be sorted and every position must only
+ * occur once.
+ * \param frozen_bit_values holds an unpacked byte for every
+ * frozen bit position. It defines if a frozen bit is
+ * fixed to '0' or '1'. Defaults to all ZERO.
+ */
+ static generic_decoder::sptr make(int block_size, int num_info_bits,
+ std::vector<int>
frozen_bit_positions,
+ std::vector<char> frozen_bit_values);
+ ~polar_decoder_sc();
- // FECAPI
- void generic_work(void *in_buffer, void *out_buffer);
+ // FECAPI
+ void generic_work(void *in_buffer, void *out_buffer);
- private:
- polar_decoder_sc(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values);
+ private:
+ polar_decoder_sc(int block_size, int num_info_bits,
+ std::vector<int> frozen_bit_positions,
+ std::vector<char> frozen_bit_values);
- float* d_llr_vec;
- unsigned char* d_u_hat_vec;
+ float* d_llr_vec;
+ unsigned char* d_u_hat_vec;
- unsigned char retrieve_bit_from_llr(float llr, const int pos);
- void sc_decode(float* llrs, unsigned char* u);
- };
+ unsigned char retrieve_bit_from_llr(float llr, const int pos);
+ void sc_decode(float* llrs, unsigned char* u);
+ };
} // namespace code
} // namespace fec
diff --git a/gr-fec/include/gnuradio/fec/polar_decoder_sc_list.h
b/gr-fec/include/gnuradio/fec/polar_decoder_sc_list.h
index 6f7033b..12b896e 100644
--- a/gr-fec/include/gnuradio/fec/polar_decoder_sc_list.h
+++ b/gr-fec/include/gnuradio/fec/polar_decoder_sc_list.h
@@ -31,61 +31,61 @@ namespace gr {
namespace fec {
namespace code {
- namespace polar {
- class scl_list;
- class path;
- }
+ namespace polar {
+ class scl_list;
+ class path;
+ }
- /*!
- * \brief Successive cancellation list (SCL) decoder for polar
- * codes.
- *
- * \details
- * Decoder is based on Tal, Vardy "List Decoding of Polar Codes",
- * 2012 LLR version: Balatsoukas-Stimming, Parizi, Burg "LLR-based
- * Successive Cancellation List Decoding of Polar Codes", 2015.
- *
- * Block expects float input with bits mapped 1 --> 1, 0 --> -1
- * Or: f = 2.0 * bit - 1.0
- */
- class FEC_API polar_decoder_sc_list : public polar_decoder_common
- {
- public:
/*!
- * \param max_list_size caps number of followed decoding paths.
- * \param block_size codeword size. MUST be a power of 2.
- * \param num_info_bits represents the number of information
- * bits in a block. Also called frame_size. <= block_size
- * \param frozen_bit_positions is an integer vector which
- * defines the position of all frozen bits in a block.
- * Its size MUST be equal to block_size - num_info_bits.
- * Also it must be sorted and every position must only
- * occur once.
- * \param frozen_bit_values holds an unpacked byte for every
- * frozen bit position. It defines if a frozen bit is
- * fixed to '0' or '1'. Defaults to all ZERO.
+ * \brief Successive cancellation list (SCL) decoder for polar
+ * codes.
+ *
+ * \details
+ * Decoder is based on Tal, Vardy "List Decoding of Polar Codes",
+ * 2012 LLR version: Balatsoukas-Stimming, Parizi, Burg "LLR-based
+ * Successive Cancellation List Decoding of Polar Codes", 2015.
+ *
+ * Block expects float input with bits mapped 1 --> 1, 0 --> -1
+ * Or: f = 2.0 * bit - 1.0
*/
- static generic_decoder::sptr make(int max_list_size, int block_size,
- int num_info_bits, std::vector<int>
frozen_bit_positions,
- std::vector<char> frozen_bit_values);
- ~polar_decoder_sc_list();
+ class FEC_API polar_decoder_sc_list : public polar_decoder_common
+ {
+ public:
+ /*!
+ * \param max_list_size caps number of followed decoding paths.
+ * \param block_size codeword size. MUST be a power of 2.
+ * \param num_info_bits represents the number of information
+ * bits in a block. Also called frame_size. <= block_size
+ * \param frozen_bit_positions is an integer vector which
+ * defines the position of all frozen bits in a block.
+ * Its size MUST be equal to block_size - num_info_bits.
+ * Also it must be sorted and every position must only
+ * occur once.
+ * \param frozen_bit_values holds an unpacked byte for every
+ * frozen bit position. It defines if a frozen bit is
+ * fixed to '0' or '1'. Defaults to all ZERO.
+ */
+ static generic_decoder::sptr make(int max_list_size, int block_size,
+ int num_info_bits, std::vector<int>
frozen_bit_positions,
+ std::vector<char> frozen_bit_values);
+ ~polar_decoder_sc_list();
- // FECAPI
- void generic_work(void *in_buffer, void *out_buffer);
+ // FECAPI
+ void generic_work(void *in_buffer, void *out_buffer);
- private:
- polar_decoder_sc_list(int max_list_size, int block_size,
- int num_info_bits, std::vector<int>
frozen_bit_positions,
- std::vector<char> frozen_bit_values);
+ private:
+ polar_decoder_sc_list(int max_list_size, int block_size,
+ int num_info_bits, std::vector<int>
frozen_bit_positions,
+ std::vector<char> frozen_bit_values);
- polar::scl_list* d_scl;
+ polar::scl_list* d_scl;
- void initialize_list(const float* in_buf);
- const unsigned char* decode_list();
- void decode_bit(const int u_num);
- void calculate_llrs_for_list(const int u_num);
- void set_bit_in_list(const int u_num);
- };
+ void initialize_list(const float* in_buf);
+ const unsigned char* decode_list();
+ void decode_bit(const int u_num);
+ void calculate_llrs_for_list(const int u_num);
+ void set_bit_in_list(const int u_num);
+ };
} // namespace code
} // namespace fec
diff --git a/gr-fec/include/gnuradio/fec/polar_encoder.h
b/gr-fec/include/gnuradio/fec/polar_encoder.h
index e3b4557..f9541a2 100644
--- a/gr-fec/include/gnuradio/fec/polar_encoder.h
+++ b/gr-fec/include/gnuradio/fec/polar_encoder.h
@@ -32,86 +32,86 @@ namespace gr {
namespace fec {
namespace code {
- /*!
- * \brief POLAR encoder
- * for basic details see 'polar_common' class.
- * \ingroup error_coding_blk
- *
- * \details
- * expects values with MSB first. It needs a full information word and
encodes it in one pass.
- * Output is a codeword of block_size.
- */
- class FEC_API polar_encoder : public generic_encoder, public polar_common
- {
- public:
/*!
- * Factory for a polar code encoder object.
+ * \brief POLAR encoder
+ * for basic details see 'polar_common' class.
+ * \ingroup error_coding_blk
*
- * \param block_size defines the codeword size. It MUST be a
- * power of 2.
- * \param num_info_bits represents the number of information
- * bits in a block. Also called frame_size.
- * \param frozen_bit_positions is an integer vector which
- * defines the position of all frozen bits in a block.
- * Its size MUST be equal to block_size - num_info_bits.
- * Also it must be sorted and every position must only
- * occur once.
- * \param frozen_bit_values holds an unpacked byte for every
- * frozen bit position. It defines if a frozen bit is
- * fixed to '0' or '1'. Defaults to all ZERO.
- * \param is_packed choose 1 active bit/byte or 8 active
- * bit/byte. if false, VOLK polar encoder is used.
+ * \details
+ * expects values with MSB first. It needs a full information word and
encodes it in one pass.
+ * Output is a codeword of block_size.
*/
- static generic_encoder::sptr make(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values,
- bool is_packed = false);
- ~polar_encoder();
+ class FEC_API polar_encoder : public generic_encoder, public polar_common
+ {
+ public:
+ /*!
+ * Factory for a polar code encoder object.
+ *
+ * \param block_size defines the codeword size. It MUST be a
+ * power of 2.
+ * \param num_info_bits represents the number of information
+ * bits in a block. Also called frame_size.
+ * \param frozen_bit_positions is an integer vector which
+ * defines the position of all frozen bits in a block.
+ * Its size MUST be equal to block_size - num_info_bits.
+ * Also it must be sorted and every position must only
+ * occur once.
+ * \param frozen_bit_values holds an unpacked byte for every
+ * frozen bit position. It defines if a frozen bit is
+ * fixed to '0' or '1'. Defaults to all ZERO.
+ * \param is_packed choose 1 active bit/byte or 8 active
+ * bit/byte. if false, VOLK polar encoder is used.
+ */
+ static generic_encoder::sptr make(int block_size, int num_info_bits,
+ std::vector<int>
frozen_bit_positions,
+ std::vector<char> frozen_bit_values,
+ bool is_packed = false);
+ ~polar_encoder();
- // FECAPI
- void generic_work(void *in_buffer, void *out_buffer);
- double rate(){return (1.0 * get_input_size() / get_output_size());};
- int get_input_size(){return num_info_bits() / (d_is_packed ? 8 : 1);};
- int get_output_size(){return block_size() / (d_is_packed ? 8 : 1);};
- bool set_frame_size(unsigned int frame_size){return false;};
- const char* get_input_conversion(){return d_is_packed ? "pack" :
"none";};
- const char* get_output_conversion(){return d_is_packed ? "packed_bits" :
"none";};
+ // FECAPI
+ void generic_work(void *in_buffer, void *out_buffer);
+ double rate(){return (1.0 * get_input_size() / get_output_size());};
+ int get_input_size(){return num_info_bits() / (d_is_packed ? 8 : 1);};
+ int get_output_size(){return block_size() / (d_is_packed ? 8 : 1);};
+ bool set_frame_size(unsigned int frame_size){return false;};
+ const char* get_input_conversion(){return d_is_packed ? "pack" :
"none";};
+ const char* get_output_conversion(){return d_is_packed ? "packed_bits"
: "none";};
- private:
- polar_encoder(int block_size, int num_info_bits,
- std::vector<int>& frozen_bit_positions,
- std::vector<char>& frozen_bit_values, bool is_packed);
- std::vector<int> d_info_bit_reversed_positions;
- bool d_is_packed;
+ private:
+ polar_encoder(int block_size, int num_info_bits,
+ std::vector<int>& frozen_bit_positions,
+ std::vector<char>& frozen_bit_values, bool is_packed);
+ std::vector<int> d_info_bit_reversed_positions;
+ bool d_is_packed;
- // c'tor method for packed algorithm setup.
- void setup_frozen_bit_inserter();
+ // c'tor method for packed algorithm setup.
+ void setup_frozen_bit_inserter();
- // methods insert input bits and frozen bits into packed array for
encoding
- unsigned char* d_frozen_bit_prototype; // packed frozen bits are written
onto it and later copies are used.
- void insert_packed_frozen_bits_and_reverse(unsigned char* target,
- const unsigned char* input)
const;
- void insert_unpacked_bit_into_packed_array_at_position(unsigned char*
target,
+ // methods insert input bits and frozen bits into packed array for
encoding
+ unsigned char* d_frozen_bit_prototype; // packed frozen bits are
written onto it and later copies are used.
+ void insert_packed_frozen_bits_and_reverse(unsigned char* target,
+ const unsigned char* input)
const;
+ void insert_unpacked_bit_into_packed_array_at_position(unsigned char*
target,
+ const unsigned
char bit,
+ const int pos)
const;
+ void insert_packet_bit_into_packed_array_at_position(unsigned char*
target,
const unsigned
char bit,
- const int pos)
const;
- void insert_packet_bit_into_packed_array_at_position(unsigned char*
target,
- const unsigned char
bit,
- const int
target_pos,
- const int bit_pos)
const;
+ const int
target_pos,
+ const int
bit_pos) const;
- // packed encoding methods
- void encode_vector_packed(unsigned char* target) const;
- void encode_vector_packed_subbyte(unsigned char* target) const;
- void encode_packed_byte(unsigned char* target) const;
- void encode_vector_packed_interbyte(unsigned char* target) const;
+ // packed encoding methods
+ void encode_vector_packed(unsigned char* target) const;
+ void encode_vector_packed_subbyte(unsigned char* target) const;
+ void encode_packed_byte(unsigned char* target) const;
+ void encode_vector_packed_interbyte(unsigned char* target) const;
- // VOLK methods
- void setup_volk_vectors();
- void volk_encode(unsigned char* out_buf, const unsigned char* in_buf);
- unsigned char* d_temp;
- unsigned char* d_frozen_bit_mask;
- unsigned char* d_frozen_bits;
- };
+ // VOLK methods
+ void setup_volk_vectors();
+ void volk_encode(unsigned char* out_buf, const unsigned char* in_buf);
+ unsigned char* d_temp;
+ unsigned char* d_frozen_bit_mask;
+ unsigned char* d_frozen_bits;
+ };
} // namespace code
} // namespace fec
diff --git a/gr-fec/lib/polar_common.cc b/gr-fec/lib/polar_common.cc
index 9952ba0..ff78d34 100644
--- a/gr-fec/lib/polar_common.cc
+++ b/gr-fec/lib/polar_common.cc
@@ -39,97 +39,97 @@ namespace gr {
namespace fec {
namespace code {
- polar_common::polar_common(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values) :
- d_frozen_bit_positions(frozen_bit_positions),
d_frozen_bit_values(frozen_bit_values),
- d_block_size(block_size), d_block_power((int)
log2(float(block_size))),
- d_num_info_bits(num_info_bits)
- {
- if(pow(2, d_block_power) != d_block_size){
- throw std::runtime_error("block_size MUST be a power of 2!");
- }
+ polar_common::polar_common(int block_size, int num_info_bits,
+ std::vector<int> frozen_bit_positions,
+ std::vector<char> frozen_bit_values) :
+ d_frozen_bit_positions(frozen_bit_positions),
d_frozen_bit_values(frozen_bit_values),
+ d_block_size(block_size), d_block_power((int) log2(float(block_size))),
+ d_num_info_bits(num_info_bits)
+ {
+ if(pow(2, d_block_power) != d_block_size){
+ throw std::runtime_error("block_size MUST be a power of 2!");
+ }
- unsigned int num_frozen_bits = d_block_size - d_num_info_bits;
- if(num_frozen_bits != d_frozen_bit_positions.size()){
- throw std::runtime_error(
- "number of frozen bit positions must equal block_size -
num_info_bits");
- }
+ unsigned int num_frozen_bits = d_block_size - d_num_info_bits;
+ if(num_frozen_bits != d_frozen_bit_positions.size()){
+ throw std::runtime_error(
+ "number of frozen bit positions must equal
block_size - num_info_bits");
+ }
- // According to papers frozen bits default to '0'.
- while(d_frozen_bit_values.size() < num_frozen_bits){
- d_frozen_bit_values.push_back(0);
+ // According to papers frozen bits default to '0'.
+ while(d_frozen_bit_values.size() < num_frozen_bits){
+ d_frozen_bit_values.push_back(0);
+ }
+ initialize_info_bit_position_vector();
+
+ d_unpacker = new gr::blocks::kernel::unpack_k_bits(8);
}
- initialize_info_bit_position_vector();
-
- d_unpacker = new gr::blocks::kernel::unpack_k_bits(8);
- }
-
- void
- polar_common::initialize_info_bit_position_vector()
- {
- int num_frozen_bit = 0;
- int frozen_pos = d_frozen_bit_positions.at(num_frozen_bit);
- for(int i = 0; i < d_block_size; i++) {
- if(i != frozen_pos) {
- d_info_bit_positions.push_back((int) i);
+
+ void
+ polar_common::initialize_info_bit_position_vector()
+ {
+ int num_frozen_bit = 0;
+ int frozen_pos = d_frozen_bit_positions.at(num_frozen_bit);
+ for(int i = 0; i < d_block_size; i++) {
+ if(i != frozen_pos) {
+ d_info_bit_positions.push_back((int) i);
+ }
+ else {
+ num_frozen_bit++;
+ num_frozen_bit = std::min(num_frozen_bit, (int)
(d_frozen_bit_positions.size() - 1));
+ frozen_pos = d_frozen_bit_positions.at(num_frozen_bit);
+ }
}
- else {
- num_frozen_bit++;
- num_frozen_bit = std::min(num_frozen_bit, (int)
(d_frozen_bit_positions.size() - 1));
- frozen_pos = d_frozen_bit_positions.at(num_frozen_bit);
+
+ if((int) d_info_bit_positions.size() != num_info_bits()) {
+ throw std::runtime_error("polar_common: number of info bit positions
MUST equal num_info_bits (K)!");
}
}
- if((int) d_info_bit_positions.size() != num_info_bits()) {
- throw std::runtime_error("polar_common: number of info bit positions
MUST equal num_info_bits (K)!");
+ polar_common::~polar_common()
+ {
+ delete d_unpacker;
}
- }
-
- polar_common::~polar_common()
- {
- delete d_unpacker;
- }
-
- long
- polar_common::bit_reverse(long value, int active_bits) const
- {
- long r = 0;
- for(int i = 0; i < active_bits; i++) {
- r <<= 1;
- r |= value & 1;
- value >>= 1;
+
+ long
+ polar_common::bit_reverse(long value, int active_bits) const
+ {
+ long r = 0;
+ for(int i = 0; i < active_bits; i++) {
+ r <<= 1;
+ r |= value & 1;
+ value >>= 1;
+ }
+ return r;
}
- return r;
- }
-
- void
- polar_common::print_packed_bit_array(const unsigned char* printed_array,
- const int num_bytes) const
- {
- int num_bits = num_bytes << 3;
- unsigned char* temp = new unsigned char[num_bits];
- d_unpacker->unpack(temp, printed_array, num_bytes);
-
- std::cout << "[";
- for(int i = 0; i < num_bits; i++) {
- std::cout << (int) *(temp + i) << " ";
+
+ void
+ polar_common::print_packed_bit_array(const unsigned char* printed_array,
+ const int num_bytes) const
+ {
+ int num_bits = num_bytes << 3;
+ unsigned char* temp = new unsigned char[num_bits];
+ d_unpacker->unpack(temp, printed_array, num_bytes);
+
+ std::cout << "[";
+ for(int i = 0; i < num_bits; i++) {
+ std::cout << (int) *(temp + i) << " ";
+ }
+ std::cout << "]" << std::endl;
+
+ delete [] temp;
}
- std::cout << "]" << std::endl;
-
- delete [] temp;
- }
-
- void
- polar_common::print_unpacked_bit_array(const unsigned char* bits,
- const unsigned int
num_bytes) const
- {
- std::cout << "( ";
- for(unsigned int i = 0; i < num_bytes; i++){
- std::cout << (int) *bits++ << ", ";
+
+ void
+ polar_common::print_unpacked_bit_array(const unsigned char* bits,
+ const unsigned int num_bytes)
const
+ {
+ std::cout << "( ";
+ for(unsigned int i = 0; i < num_bytes; i++){
+ std::cout << (int) *bits++ << ", ";
+ }
+ std::cout << ")" << std::endl;
}
- std::cout << ")" << std::endl;
- }
} /* namespace code */
} /* namespace fec */
diff --git a/gr-fec/lib/polar_decoder_common.cc
b/gr-fec/lib/polar_decoder_common.cc
index cb5a6db..8fc2e37 100644
--- a/gr-fec/lib/polar_decoder_common.cc
+++ b/gr-fec/lib/polar_decoder_common.cc
@@ -34,159 +34,159 @@ namespace gr {
namespace fec {
namespace code {
- polar_decoder_common::polar_decoder_common(int block_size, int
num_info_bits,
- std::vector<int>
frozen_bit_positions,
- std::vector<char>
frozen_bit_values) :
- polar_common(block_size, num_info_bits, frozen_bit_positions,
frozen_bit_values),
- d_frozen_bit_counter(0)
- {
- }
-
- polar_decoder_common::~polar_decoder_common()
- {
- }
-
- void
- polar_decoder_common::initialize_decoder(unsigned char* u, float* llrs,
const float* input)
- {
- volk_32f_s32f_multiply_32f(llrs + block_size() * block_power(), input,
D_LLR_FACTOR, block_size());
- memset(u, 0, sizeof(unsigned char) * block_size() * block_power());
- d_frozen_bit_counter = 0;
- }
-
- float
- polar_decoder_common::llr_odd(const float la, const float lb) const
- {
- return copysignf(1.0f, la) * copysignf(1.0f, lb) * std::min(fabs(la),
fabs(lb));
- }
-
- float
- polar_decoder_common::llr_even(const float la, const float lb, const
unsigned char f) const
- {
- switch(f){
+ polar_decoder_common::polar_decoder_common(int block_size, int
num_info_bits,
+ std::vector<int>
frozen_bit_positions,
+ std::vector<char>
frozen_bit_values) :
+ polar_common(block_size, num_info_bits, frozen_bit_positions,
frozen_bit_values),
+ d_frozen_bit_counter(0)
+ {
+ }
+
+ polar_decoder_common::~polar_decoder_common()
+ {
+ }
+
+ void
+ polar_decoder_common::initialize_decoder(unsigned char* u, float* llrs,
const float* input)
+ {
+ volk_32f_s32f_multiply_32f(llrs + block_size() * block_power(), input,
D_LLR_FACTOR, block_size());
+ memset(u, 0, sizeof(unsigned char) * block_size() * block_power());
+ d_frozen_bit_counter = 0;
+ }
+
+ float
+ polar_decoder_common::llr_odd(const float la, const float lb) const
+ {
+ return copysignf(1.0f, la) * copysignf(1.0f, lb) * std::min(fabs(la),
fabs(lb));
+ }
+
+ float
+ polar_decoder_common::llr_even(const float la, const float lb, const
unsigned char f) const
+ {
+ switch(f){
case 0:
return lb + la;
default:
return lb - la;
+ }
}
- }
-
- void
- polar_decoder_common::butterfly(float* llrs, unsigned char* u, const int
stage, const int u_num,
- const int row)
- {
- butterfly_volk(llrs, u, stage, u_num, row);
- }
-
- void
- polar_decoder_common::butterfly_generic(float* llrs, unsigned char* u,
const int stage,
- const int u_num, const int row)
- {
- const int next_stage = stage + 1;
- const int half_stage_size = 0x01 << stage;
- const int stage_size = half_stage_size << 1;
- const bool is_upper_stage_half = row % stage_size < half_stage_size;
-
- // // this is a natural bit order impl
- float* next_llrs = llrs + block_size(); // LLRs are stored in a
consecutive array.
- float* call_row_llr = llrs + row;
-
- const int section = row - (row % stage_size);
- const int jump_size = ((row % half_stage_size) << 1) % stage_size;
-
- const int next_upper_row = section + jump_size;
- const int next_lower_row = next_upper_row + 1;
-
- const float* upper_right_llr_ptr = next_llrs + next_upper_row;
- const float* lower_right_llr_ptr = next_llrs + next_lower_row;
-
- if(!is_upper_stage_half){
- const int u_pos = u_num >> stage;
- const unsigned char f = u[u_pos - 1];
- *call_row_llr = llr_even(*upper_right_llr_ptr, *lower_right_llr_ptr,
f);
- return;
+
+ void
+ polar_decoder_common::butterfly(float* llrs, unsigned char* u, const int
stage,
+ const int u_num, const int row)
+ {
+ butterfly_volk(llrs, u, stage, u_num, row);
}
- if(block_power() > next_stage){
- unsigned char* u_half = u + block_size();
- odd_xor_even_values(u_half, u, u_num);
- butterfly(next_llrs, u_half, next_stage, u_num, next_upper_row);
+ void
+ polar_decoder_common::butterfly_generic(float* llrs, unsigned char* u,
const int stage,
+ const int u_num, const int row)
+ {
+ const int next_stage = stage + 1;
+ const int half_stage_size = 0x01 << stage;
+ const int stage_size = half_stage_size << 1;
+ const bool is_upper_stage_half = row % stage_size < half_stage_size;
+
+ // // this is a natural bit order impl
+ float* next_llrs = llrs + block_size(); // LLRs are stored in a
consecutive array.
+ float* call_row_llr = llrs + row;
+
+ const int section = row - (row % stage_size);
+ const int jump_size = ((row % half_stage_size) << 1) % stage_size;
+
+ const int next_upper_row = section + jump_size;
+ const int next_lower_row = next_upper_row + 1;
+
+ const float* upper_right_llr_ptr = next_llrs + next_upper_row;
+ const float* lower_right_llr_ptr = next_llrs + next_lower_row;
+
+ if(!is_upper_stage_half){
+ const int u_pos = u_num >> stage;
+ const unsigned char f = u[u_pos - 1];
+ *call_row_llr = llr_even(*upper_right_llr_ptr, *lower_right_llr_ptr,
f);
+ return;
+ }
+
+ if(block_power() > next_stage){
+ unsigned char* u_half = u + block_size();
+ odd_xor_even_values(u_half, u, u_num);
+ butterfly(next_llrs, u_half, next_stage, u_num, next_upper_row);
+
+ even_u_values(u_half, u, u_num);
+ butterfly(next_llrs, u_half, next_stage, u_num, next_lower_row);
+ }
- even_u_values(u_half, u, u_num);
- butterfly(next_llrs, u_half, next_stage, u_num, next_lower_row);
+ *call_row_llr = llr_odd(*upper_right_llr_ptr, *lower_right_llr_ptr);
}
- *call_row_llr = llr_odd(*upper_right_llr_ptr, *lower_right_llr_ptr);
- }
-
- void
- polar_decoder_common::butterfly_volk(float* llrs, unsigned char* u, const
int stage,
- const int u_num, const int row)
- {
- volk_32f_8u_polarbutterfly_32f(llrs, u, block_size(), block_power(),
stage, u_num, row);
- }
-
-
- void
- polar_decoder_common::even_u_values(unsigned char* u_even, const unsigned
char* u,
- const int u_num)
- {
- u++;
- for(int i = 1; i < u_num; i += 2){
- *u_even++ = *u;
- u += 2;
+ void
+ polar_decoder_common::butterfly_volk(float* llrs, unsigned char* u,
const int stage,
+ const int u_num, const int row)
+ {
+ volk_32f_8u_polarbutterfly_32f(llrs, u, block_size(), block_power(),
stage, u_num, row);
}
- }
-
- void
- polar_decoder_common::odd_xor_even_values(unsigned char* u_xor, const
unsigned char* u,
- const int u_num)
- {
- for(int i = 1; i < u_num; i += 2){
- *u_xor++ = *u ^ *(u + 1);
- u += 2;
+
+
+ void
+ polar_decoder_common::even_u_values(unsigned char* u_even, const
unsigned char* u,
+ const int u_num)
+ {
+ u++;
+ for(int i = 1; i < u_num; i += 2){
+ *u_even++ = *u;
+ u += 2;
+ }
}
- }
-
- const bool
- polar_decoder_common::is_frozen_bit(const int u_num) const
- {
- return d_frozen_bit_counter < d_frozen_bit_positions.size() && u_num ==
d_frozen_bit_positions.at(d_frozen_bit_counter);
- }
-
-
- const unsigned char
- polar_decoder_common::next_frozen_bit()
- {
- return d_frozen_bit_values[d_frozen_bit_counter++];
- }
-
- void
- polar_decoder_common::extract_info_bits(unsigned char* output, const
unsigned char* input) const
- {
- unsigned int frozenbit_num = 0;
- for(int i = 0; i < block_size(); i++){
- if(frozenbit_num < d_frozen_bit_positions.size() &&
d_frozen_bit_positions.at(frozenbit_num) == i){
- frozenbit_num++;
+
+ void
+ polar_decoder_common::odd_xor_even_values(unsigned char* u_xor, const
unsigned char* u,
+ const int u_num)
+ {
+ for(int i = 1; i < u_num; i += 2){
+ *u_xor++ = *u ^ *(u + 1);
+ u += 2;
}
- else{
- *output++ = *input;
+ }
+
+ const bool
+ polar_decoder_common::is_frozen_bit(const int u_num) const
+ {
+ return d_frozen_bit_counter < d_frozen_bit_positions.size() && u_num
== d_frozen_bit_positions.at(d_frozen_bit_counter);
+ }
+
+
+ const unsigned char
+ polar_decoder_common::next_frozen_bit()
+ {
+ return d_frozen_bit_values[d_frozen_bit_counter++];
+ }
+
+ void
+ polar_decoder_common::extract_info_bits(unsigned char* output, const
unsigned char* input) const
+ {
+ unsigned int frozenbit_num = 0;
+ for(int i = 0; i < block_size(); i++){
+ if(frozenbit_num < d_frozen_bit_positions.size() &&
d_frozen_bit_positions.at(frozenbit_num) == i){
+ frozenbit_num++;
+ }
+ else{
+ *output++ = *input;
+ }
+ input++;
}
- input++;
}
- }
-
- void
- polar_decoder_common::print_pretty_llr_vector(const float* llr_vec) const
- {
- for(int row = 0; row < block_size(); row++) {
- std::cout << row << "->" << int(bit_reverse(row, block_power())) <<
":\t";
- for(int stage = 0; stage < block_power() + 1; stage++) {
- printf("%+4.2f, ", llr_vec[(stage * block_size()) + row]);
+
+ void
+ polar_decoder_common::print_pretty_llr_vector(const float* llr_vec) const
+ {
+ for(int row = 0; row < block_size(); row++) {
+ std::cout << row << "->" << int(bit_reverse(row, block_power())) <<
":\t";
+ for(int stage = 0; stage < block_power() + 1; stage++) {
+ printf("%+4.2f, ", llr_vec[(stage * block_size()) + row]);
+ }
+ std::cout << std::endl;
}
- std::cout << std::endl;
}
- }
} /* namespace code */
} /* namespace fec */
diff --git a/gr-fec/lib/polar_decoder_sc.cc b/gr-fec/lib/polar_decoder_sc.cc
index 1412946..c4ac887 100644
--- a/gr-fec/lib/polar_decoder_sc.cc
+++ b/gr-fec/lib/polar_decoder_sc.cc
@@ -35,62 +35,62 @@ namespace gr {
namespace fec {
namespace code {
- generic_decoder::sptr
- polar_decoder_sc::make(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values)
- {
- return generic_decoder::sptr
- (new polar_decoder_sc(block_size, num_info_bits,
- frozen_bit_positions,
- frozen_bit_values));
- }
+ generic_decoder::sptr
+ polar_decoder_sc::make(int block_size, int num_info_bits,
+ std::vector<int> frozen_bit_positions,
+ std::vector<char> frozen_bit_values)
+ {
+ return generic_decoder::sptr
+ (new polar_decoder_sc(block_size, num_info_bits,
+ frozen_bit_positions,
+ frozen_bit_values));
+ }
- polar_decoder_sc::polar_decoder_sc(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values) :
- polar_decoder_common(block_size, num_info_bits, frozen_bit_positions,
frozen_bit_values)
- {
- d_llr_vec = (float*) volk_malloc(sizeof(float) * block_size *
(block_power() + 1), volk_get_alignment());
- memset(d_llr_vec, 0, sizeof(float) * block_size * (block_power() + 1));
- d_u_hat_vec = (unsigned char*) volk_malloc(block_size * (block_power() +
1), volk_get_alignment());
- memset(d_u_hat_vec, 0, sizeof(unsigned char) * block_size *
(block_power() + 1));
- }
+ polar_decoder_sc::polar_decoder_sc(int block_size, int num_info_bits,
+ std::vector<int> frozen_bit_positions,
+ std::vector<char> frozen_bit_values) :
+ polar_decoder_common(block_size, num_info_bits, frozen_bit_positions,
frozen_bit_values)
+ {
+ d_llr_vec = (float*) volk_malloc(sizeof(float) * block_size *
(block_power() + 1), volk_get_alignment());
+ memset(d_llr_vec, 0, sizeof(float) * block_size * (block_power() + 1));
+ d_u_hat_vec = (unsigned char*) volk_malloc(block_size * (block_power()
+ 1), volk_get_alignment());
+ memset(d_u_hat_vec, 0, sizeof(unsigned char) * block_size *
(block_power() + 1));
+ }
- polar_decoder_sc::~polar_decoder_sc()
- {
- volk_free(d_llr_vec);
- volk_free(d_u_hat_vec);
- }
+ polar_decoder_sc::~polar_decoder_sc()
+ {
+ volk_free(d_llr_vec);
+ volk_free(d_u_hat_vec);
+ }
- void
- polar_decoder_sc::generic_work(void* in_buffer, void* out_buffer)
- {
- const float *in = (const float*) in_buffer;
- unsigned char *out = (unsigned char*) out_buffer;
+ void
+ polar_decoder_sc::generic_work(void* in_buffer, void* out_buffer)
+ {
+ const float *in = (const float*) in_buffer;
+ unsigned char *out = (unsigned char*) out_buffer;
- initialize_decoder(d_u_hat_vec, d_llr_vec, in);
- sc_decode(d_llr_vec, d_u_hat_vec);
- extract_info_bits(out, d_u_hat_vec);
- }
+ initialize_decoder(d_u_hat_vec, d_llr_vec, in);
+ sc_decode(d_llr_vec, d_u_hat_vec);
+ extract_info_bits(out, d_u_hat_vec);
+ }
- void
- polar_decoder_sc::sc_decode(float* llrs, unsigned char* u)
- {
- for(int i = 0; i < block_size(); i++){
- butterfly(llrs, u, 0, i, i);
- u[i] = retrieve_bit_from_llr(llrs[i], i);
+ void
+ polar_decoder_sc::sc_decode(float* llrs, unsigned char* u)
+ {
+ for(int i = 0; i < block_size(); i++){
+ butterfly(llrs, u, 0, i, i);
+ u[i] = retrieve_bit_from_llr(llrs[i], i);
+ }
}
- }
- unsigned char
- polar_decoder_sc::retrieve_bit_from_llr(float llr, const int pos)
- {
- if(is_frozen_bit(pos)){
- return next_frozen_bit();
+ unsigned char
+ polar_decoder_sc::retrieve_bit_from_llr(float llr, const int pos)
+ {
+ if(is_frozen_bit(pos)){
+ return next_frozen_bit();
+ }
+ return llr_bit_decision(llr);
}
- return llr_bit_decision(llr);
- }
} /* namespace code */
} /* namespace fec */
diff --git a/gr-fec/lib/polar_decoder_sc_list.cc
b/gr-fec/lib/polar_decoder_sc_list.cc
index 041cd89..903b941 100644
--- a/gr-fec/lib/polar_decoder_sc_list.cc
+++ b/gr-fec/lib/polar_decoder_sc_list.cc
@@ -36,87 +36,87 @@ namespace gr {
namespace fec {
namespace code {
- generic_decoder::sptr
- polar_decoder_sc_list::make(int max_list_size, int block_size, int
num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values)
- {
- return generic_decoder::sptr(
- new polar_decoder_sc_list(max_list_size, block_size, num_info_bits,
- frozen_bit_positions,
- frozen_bit_values));
- }
-
- polar_decoder_sc_list::polar_decoder_sc_list(int max_list_size, int
block_size,
- int num_info_bits,
- std::vector<int>
frozen_bit_positions,
- std::vector<char>
frozen_bit_values) :
- polar_decoder_common(block_size, num_info_bits, frozen_bit_positions,
frozen_bit_values)
- {
- d_scl = new polar::scl_list(max_list_size, block_size, block_power());
- }
+ generic_decoder::sptr
+ polar_decoder_sc_list::make(int max_list_size, int block_size, int
num_info_bits,
+ std::vector<int> frozen_bit_positions,
+ std::vector<char> frozen_bit_values)
+ {
+ return generic_decoder::sptr
+ (new polar_decoder_sc_list(max_list_size, block_size, num_info_bits,
+ frozen_bit_positions,
+ frozen_bit_values));
+ }
- polar_decoder_sc_list::~polar_decoder_sc_list()
- {
- delete d_scl;
- }
+ polar_decoder_sc_list::polar_decoder_sc_list(int max_list_size, int
block_size,
+ int num_info_bits,
+ std::vector<int>
frozen_bit_positions,
+ std::vector<char>
frozen_bit_values)
+ : polar_decoder_common(block_size, num_info_bits,
frozen_bit_positions, frozen_bit_values)
+ {
+ d_scl = new polar::scl_list(max_list_size, block_size, block_power());
+ }
- void
- polar_decoder_sc_list::generic_work(void* in_buffer, void* out_buffer)
- {
- const float *in = (const float*) in_buffer;
- unsigned char *out = (unsigned char*) out_buffer;
+ polar_decoder_sc_list::~polar_decoder_sc_list()
+ {
+ delete d_scl;
+ }
- initialize_list(in);
- const unsigned char* temp = decode_list();
- extract_info_bits(out, temp);
- }
+ void
+ polar_decoder_sc_list::generic_work(void* in_buffer, void* out_buffer)
+ {
+ const float *in = (const float*) in_buffer;
+ unsigned char *out = (unsigned char*) out_buffer;
- void
- polar_decoder_sc_list::initialize_list(const float* in_buf)
- {
- polar::path* init_path = d_scl->initial_path();
- initialize_decoder(init_path->u_vec, init_path->llr_vec, in_buf);
- }
+ initialize_list(in);
+ const unsigned char* temp = decode_list();
+ extract_info_bits(out, temp);
+ }
- const unsigned char*
- polar_decoder_sc_list::decode_list()
- {
- for(int u_num = 0; u_num < block_size(); u_num++){
- decode_bit(u_num);
+ void
+ polar_decoder_sc_list::initialize_list(const float* in_buf)
+ {
+ polar::path* init_path = d_scl->initial_path();
+ initialize_decoder(init_path->u_vec, init_path->llr_vec, in_buf);
}
- return d_scl->optimal_path()->u_vec;
- }
- void
- polar_decoder_sc_list::decode_bit(const int u_num)
- {
- calculate_llrs_for_list(u_num);
- set_bit_in_list(u_num);
- }
+ const unsigned char*
+ polar_decoder_sc_list::decode_list()
+ {
+ for(int u_num = 0; u_num < block_size(); u_num++){
+ decode_bit(u_num);
+ }
+ return d_scl->optimal_path()->u_vec;
+ }
- void
- polar_decoder_sc_list::calculate_llrs_for_list(const int u_num)
- {
- for(unsigned int i = 0; i < d_scl->active_size(); i++){
- polar::path* current_path = d_scl->next_active_path();
- butterfly(current_path->llr_vec, current_path->u_vec, 0, u_num, u_num);
+ void
+ polar_decoder_sc_list::decode_bit(const int u_num)
+ {
+ calculate_llrs_for_list(u_num);
+ set_bit_in_list(u_num);
}
- }
- void
- polar_decoder_sc_list::set_bit_in_list(const int u_num)
- {
- // 1. if frozen bit, update with known value
- if(is_frozen_bit(u_num)){
- const unsigned char frozen_bit = next_frozen_bit();
- d_scl->set_frozen_bit(frozen_bit, u_num);
+ void
+ polar_decoder_sc_list::calculate_llrs_for_list(const int u_num)
+ {
+ for(unsigned int i = 0; i < d_scl->active_size(); i++){
+ polar::path* current_path = d_scl->next_active_path();
+ butterfly(current_path->llr_vec, current_path->u_vec, 0, u_num,
u_num);
+ }
}
- // 2. info bit
- else{
- d_scl->set_info_bit(u_num);
+
+ void
+ polar_decoder_sc_list::set_bit_in_list(const int u_num)
+ {
+ // 1. if frozen bit, update with known value
+ if(is_frozen_bit(u_num)){
+ const unsigned char frozen_bit = next_frozen_bit();
+ d_scl->set_frozen_bit(frozen_bit, u_num);
+ }
+ // 2. info bit
+ else{
+ d_scl->set_info_bit(u_num);
+ }
}
- }
} /* namespace code */
} /* namespace fec */
diff --git a/gr-fec/lib/polar_encoder.cc b/gr-fec/lib/polar_encoder.cc
index ed5288b..350f490 100644
--- a/gr-fec/lib/polar_encoder.cc
+++ b/gr-fec/lib/polar_encoder.cc
@@ -37,197 +37,197 @@ namespace gr {
namespace fec {
namespace code {
- generic_encoder::sptr
- polar_encoder::make(int block_size, int num_info_bits,
- std::vector<int> frozen_bit_positions,
- std::vector<char> frozen_bit_values, bool is_packed)
- {
- return generic_encoder::sptr
- (new polar_encoder(block_size, num_info_bits,
- frozen_bit_positions,
- frozen_bit_values,
- is_packed));
- }
-
- polar_encoder::polar_encoder(int block_size, int num_info_bits,
- std::vector<int>& frozen_bit_positions,
- std::vector<char>& frozen_bit_values, bool
is_packed) :
+ generic_encoder::sptr
+ polar_encoder::make(int block_size, int num_info_bits,
+ std::vector<int> frozen_bit_positions,
+ std::vector<char> frozen_bit_values, bool is_packed)
+ {
+ return generic_encoder::sptr
+ (new polar_encoder(block_size, num_info_bits,
+ frozen_bit_positions,
+ frozen_bit_values,
+ is_packed));
+ }
+
+ polar_encoder::polar_encoder(int block_size, int num_info_bits,
+ std::vector<int>& frozen_bit_positions,
+ std::vector<char>& frozen_bit_values, bool
is_packed) :
polar_common(block_size, num_info_bits, frozen_bit_positions,
frozen_bit_values),
d_is_packed(is_packed)
- {
- setup_frozen_bit_inserter();
- setup_volk_vectors();
- }
-
- void
- polar_encoder::setup_frozen_bit_inserter()
- {
- d_frozen_bit_prototype = (unsigned char*) volk_malloc(block_size() >> 3,
-
volk_get_alignment());
- memset(d_frozen_bit_prototype, 0, block_size() >> 3);
-
- for(unsigned int i = 0; i < d_frozen_bit_positions.size(); i++) {
- int rev_pos = (int) bit_reverse((long) d_frozen_bit_positions.at(i),
block_power());
- unsigned char frozen_bit = (unsigned char) d_frozen_bit_values.at(i);
-
insert_unpacked_bit_into_packed_array_at_position(d_frozen_bit_prototype,
frozen_bit,
- rev_pos);
+ {
+ setup_frozen_bit_inserter();
+ setup_volk_vectors();
}
- for(unsigned int i = 0; i < d_info_bit_positions.size(); i++){
- d_info_bit_reversed_positions.push_back((int) bit_reverse((long)
d_info_bit_positions.at(i), block_power()));
+ void
+ polar_encoder::setup_frozen_bit_inserter()
+ {
+ d_frozen_bit_prototype = (unsigned char*) volk_malloc(block_size() >>
3,
+
volk_get_alignment());
+ memset(d_frozen_bit_prototype, 0, block_size() >> 3);
+
+ for(unsigned int i = 0; i < d_frozen_bit_positions.size(); i++) {
+ int rev_pos = (int) bit_reverse((long) d_frozen_bit_positions.at(i),
block_power());
+ unsigned char frozen_bit = (unsigned char) d_frozen_bit_values.at(i);
+
insert_unpacked_bit_into_packed_array_at_position(d_frozen_bit_prototype,
frozen_bit,
+ rev_pos);
+ }
+
+ for(unsigned int i = 0; i < d_info_bit_positions.size(); i++){
+ d_info_bit_reversed_positions.push_back((int) bit_reverse((long)
d_info_bit_positions.at(i), block_power()));
+ }
+
+ if((int) d_info_bit_reversed_positions.size() != num_info_bits()) {
+ throw std::runtime_error("polar_encoder: number of info bit
positions MUST equal num_info_bits (K)!");
+ }
}
- if((int) d_info_bit_reversed_positions.size() != num_info_bits()) {
- throw std::runtime_error("polar_encoder: number of info bit positions
MUST equal num_info_bits (K)!");
+ void
+ polar_encoder::setup_volk_vectors()
+ {
+ int nfrozen = block_size() - num_info_bits();
+ d_temp = (unsigned char*) volk_malloc(sizeof(unsigned char) *
block_size(), volk_get_alignment());
+ d_frozen_bit_mask = (unsigned char*) volk_malloc(sizeof(unsigned char)
* block_size(), volk_get_alignment());
+ d_frozen_bits = (unsigned char*) volk_malloc(sizeof(unsigned char) *
nfrozen, volk_get_alignment());
+ for(int i = 0; i < nfrozen; i++){
+ d_frozen_bits[i] = d_frozen_bit_values[i];
+ }
+
+ int nfbit = 0;
+ for(int i = 0; i < block_size(); i++){
+ unsigned char m = 0x00;
+ if(d_frozen_bit_positions[nfbit] == i){
+ m = 0xFF;
+ nfbit++;
+ }
+ d_frozen_bit_mask[i] = m;
+ }
}
- }
-
- void
- polar_encoder::setup_volk_vectors()
- {
- int nfrozen = block_size() - num_info_bits();
- d_temp = (unsigned char*) volk_malloc(sizeof(unsigned char) *
block_size(), volk_get_alignment());
- d_frozen_bit_mask = (unsigned char*) volk_malloc(sizeof(unsigned char) *
block_size(), volk_get_alignment());
- d_frozen_bits = (unsigned char*) volk_malloc(sizeof(unsigned char) *
nfrozen, volk_get_alignment());
- for(int i = 0; i < nfrozen; i++){
- d_frozen_bits[i] = d_frozen_bit_values[i];
+
+ polar_encoder::~polar_encoder()
+ {
+ volk_free(d_frozen_bit_prototype);
+
+ volk_free(d_temp);
+ volk_free(d_frozen_bit_mask);
+ volk_free(d_frozen_bits);
}
- int nfbit = 0;
- for(int i = 0; i < block_size(); i++){
- unsigned char m = 0x00;
- if(d_frozen_bit_positions[nfbit] == i){
- m = 0xFF;
- nfbit++;
+ void
+ polar_encoder::generic_work(void* in_buffer, void* out_buffer)
+ {
+ const unsigned char *in = (const unsigned char*) in_buffer;
+ unsigned char *out = (unsigned char*) out_buffer;
+
+ if(d_is_packed){
+ insert_packed_frozen_bits_and_reverse(out, in);
+ encode_vector_packed(out);
+ }
+ else{
+ volk_encode(out, in);
}
- d_frozen_bit_mask[i] = m;
}
- }
-
- polar_encoder::~polar_encoder()
- {
- volk_free(d_frozen_bit_prototype);
-
- volk_free(d_temp);
- volk_free(d_frozen_bit_mask);
- volk_free(d_frozen_bits);
- }
-
- void
- polar_encoder::generic_work(void* in_buffer, void* out_buffer)
- {
- const unsigned char *in = (const unsigned char*) in_buffer;
- unsigned char *out = (unsigned char*) out_buffer;
-
- if(d_is_packed){
- insert_packed_frozen_bits_and_reverse(out, in);
- encode_vector_packed(out);
+
+ void
+ polar_encoder::volk_encode(unsigned char* out_buf, const unsigned char*
in_buf)
+ {
+ volk_8u_x3_encodepolar_8u_x2(out_buf, d_temp, d_frozen_bit_mask,
d_frozen_bits, in_buf, block_size());
}
- else{
- volk_encode(out, in);
+
+ void
+ polar_encoder::encode_vector_packed(unsigned char* target) const
+ {
+ encode_vector_packed_subbyte(target);
+ encode_vector_packed_interbyte(target);
}
- }
-
- void
- polar_encoder::volk_encode(unsigned char* out_buf, const unsigned char*
in_buf)
- {
- volk_8u_x3_encodepolar_8u_x2(out_buf, d_temp, d_frozen_bit_mask,
d_frozen_bits, in_buf, block_size());
- }
-
- void
- polar_encoder::encode_vector_packed(unsigned char* target) const
- {
- encode_vector_packed_subbyte(target);
- encode_vector_packed_interbyte(target);
- }
-
- void
- polar_encoder::encode_vector_packed_subbyte(unsigned char* target) const
- {
- int num_bytes_per_block = block_size() >> 3;
- while(num_bytes_per_block) {
- encode_packed_byte(target);
- ++target;
- --num_bytes_per_block;
+
+ void
+ polar_encoder::encode_vector_packed_subbyte(unsigned char* target) const
+ {
+ int num_bytes_per_block = block_size() >> 3;
+ while(num_bytes_per_block) {
+ encode_packed_byte(target);
+ ++target;
+ --num_bytes_per_block;
+ }
+ }
+
+ void
+ polar_encoder::encode_packed_byte(unsigned char* target) const
+ {
+ // this method only produces correct results if block_size > 4.
+ // this is assumed to be the case.
+ *target ^= 0xaa & (*target << 1);
+ *target ^= 0xcc & (*target << 2);
+ *target ^= *target << 4;
}
- }
-
- void
- polar_encoder::encode_packed_byte(unsigned char* target) const
- {
- // this method only produces correct results if block_size > 4.
- // this is assumed to be the case.
- *target ^= 0xaa & (*target << 1);
- *target ^= 0xcc & (*target << 2);
- *target ^= *target << 4;
- }
-
- void
- polar_encoder::encode_vector_packed_interbyte(unsigned char* target) const
- {
- int branch_byte_size = 1;
- unsigned char* pos;
- int n_branches = block_size() >> 4;
- int byte = 0;
- for(int stage = 3; stage < block_power(); ++stage) {
- pos = target;
-
- for(int branch = 0; branch < n_branches; ++branch) {
-
- byte = 0;
- while(byte < branch_byte_size) {
- *pos ^= *(pos + branch_byte_size);
- ++pos;
- ++byte;
+
+ void
+ polar_encoder::encode_vector_packed_interbyte(unsigned char* target)
const
+ {
+ int branch_byte_size = 1;
+ unsigned char* pos;
+ int n_branches = block_size() >> 4;
+ int byte = 0;
+ for(int stage = 3; stage < block_power(); ++stage) {
+ pos = target;
+
+ for(int branch = 0; branch < n_branches; ++branch) {
+
+ byte = 0;
+ while(byte < branch_byte_size) {
+ *pos ^= *(pos + branch_byte_size);
+ ++pos;
+ ++byte;
+ }
+
+ pos += branch_byte_size;
}
- pos += branch_byte_size;
+ n_branches >>= 1;
+ branch_byte_size <<= 1;
}
-
- n_branches >>= 1;
- branch_byte_size <<= 1;
}
- }
-
- void
- polar_encoder::insert_packed_frozen_bits_and_reverse(unsigned char* target,
- const unsigned char*
input) const
- {
- memcpy(target, d_frozen_bit_prototype, block_size() >> 3);
- const int* info_bit_reversed_positions_ptr =
&d_info_bit_reversed_positions[0];
- int bit_num = 0;
- unsigned char byte = *input;
- int bit_pos;
- while(bit_num < num_info_bits()) {
- bit_pos = *info_bit_reversed_positions_ptr++;
- insert_packet_bit_into_packed_array_at_position(target, byte, bit_pos,
bit_num % 8);
- ++bit_num;
- if(bit_num % 8 == 0) {
- ++input;
- byte = *input;
+
+ void
+ polar_encoder::insert_packed_frozen_bits_and_reverse(unsigned char*
target,
+ const unsigned
char* input) const
+ {
+ memcpy(target, d_frozen_bit_prototype, block_size() >> 3);
+ const int* info_bit_reversed_positions_ptr =
&d_info_bit_reversed_positions[0];
+ int bit_num = 0;
+ unsigned char byte = *input;
+ int bit_pos;
+ while(bit_num < num_info_bits()) {
+ bit_pos = *info_bit_reversed_positions_ptr++;
+ insert_packet_bit_into_packed_array_at_position(target, byte,
bit_pos, bit_num % 8);
+ ++bit_num;
+ if(bit_num % 8 == 0) {
+ ++input;
+ byte = *input;
+ }
}
}
- }
- void
- polar_encoder::insert_unpacked_bit_into_packed_array_at_position(unsigned
char* target,
+ void
+
polar_encoder::insert_unpacked_bit_into_packed_array_at_position(unsigned char*
target,
+ const
unsigned char bit,
+ const
int pos) const
+ {
+ int byte_pos = pos >> 3;
+ int bit_pos = pos & 0x7;
+ *(target + byte_pos) ^= bit << (7 - bit_pos);
+ }
+
+ void
+ polar_encoder::insert_packet_bit_into_packed_array_at_position(unsigned
char* target,
const
unsigned char bit,
- const int
pos) const
- {
- int byte_pos = pos >> 3;
- int bit_pos = pos & 0x7;
- *(target + byte_pos) ^= bit << (7 - bit_pos);
- }
-
- void
- polar_encoder::insert_packet_bit_into_packed_array_at_position(unsigned
char* target,
- const
unsigned char bit,
- const int
target_pos,
- const int
bit_pos) const
- {
- insert_unpacked_bit_into_packed_array_at_position(target, (bit >> (7 -
bit_pos)) & 0x01,
- target_pos);
- }
+ const int
target_pos,
+ const int
bit_pos) const
+ {
+ insert_unpacked_bit_into_packed_array_at_position(target, (bit >> (7 -
bit_pos)) & 0x01,
+ target_pos);
+ }
} /* namespace code */
} /* namespace fec */
diff --git a/gr-fec/lib/scl_list.cc b/gr-fec/lib/scl_list.cc
index 5ad8037..ab6e81d 100644
--- a/gr-fec/lib/scl_list.cc
+++ b/gr-fec/lib/scl_list.cc
@@ -31,163 +31,163 @@ namespace gr {
namespace code {
namespace polar {
- scl_list::scl_list(const unsigned int size,
- const unsigned int block_size,
- const unsigned int block_power):
+ scl_list::scl_list(const unsigned int size,
+ const unsigned int block_size,
+ const unsigned int block_power):
d_list_size(size), d_block_size(block_size),
d_block_power(block_power),
d_num_buff_elements(block_size * (block_power + 1))
- {
- for(unsigned int i = 0; i < 2 * size; i++){
- d_path_list.push_back(new path());
+ {
+ for(unsigned int i = 0; i < 2 * size; i++){
+ d_path_list.push_back(new path());
+ }
+
+ for(unsigned int i = 0; i < size; i++){
+ d_path_list[i]->llr_vec = (float*) volk_malloc(sizeof(float) *
d_num_buff_elements, volk_get_alignment());
+ memset(d_path_list[i]->llr_vec, 0, sizeof(float) *
d_num_buff_elements);
+ d_path_list[i]->u_vec = (unsigned char*)
volk_malloc(sizeof(unsigned char) * d_num_buff_elements, volk_get_alignment());
+ memset(d_path_list[i]->u_vec, 0, sizeof(unsigned char) *
d_num_buff_elements);
+ d_path_list[i]->owns_vectors = true;
+ }
+
+ d_path_list[0]->is_active = true;
+ d_active_path_counter = 1;
+ d_active_pos = 0;
}
- for(unsigned int i = 0; i < size; i++){
- d_path_list[i]->llr_vec = (float*) volk_malloc(sizeof(float) *
d_num_buff_elements, volk_get_alignment());
- memset(d_path_list[i]->llr_vec, 0, sizeof(float) *
d_num_buff_elements);
- d_path_list[i]->u_vec = (unsigned char*) volk_malloc(sizeof(unsigned
char) * d_num_buff_elements, volk_get_alignment());
- memset(d_path_list[i]->u_vec, 0, sizeof(unsigned char) *
d_num_buff_elements);
- d_path_list[i]->owns_vectors = true;
+ scl_list::~scl_list()
+ {
+ for(unsigned int i = 0; i < d_path_list.size(); i++){
+ delete d_path_list[i];
+ }
}
- d_path_list[0]->is_active = true;
- d_active_path_counter = 1;
- d_active_pos = 0;
- }
- scl_list::~scl_list()
- {
- for(unsigned int i = 0; i < d_path_list.size(); i++){
- delete d_path_list[i];
- }
- }
-
-
- const path*
- scl_list::optimal_path()
- {
- const path* temp = *std::min_element(d_path_list.begin(),
d_path_list.begin() + d_active_path_counter, path_compare);
- reset();
- return temp;
- }
-
- void
- scl_list::reset()
- {
- // leave 0th element active for next iteration
- d_path_list[0]->path_metric = 0.0f;
- for(unsigned int i = 1; i < d_path_list.size(); i++){
- d_path_list[i]->is_active = false;
- d_path_list[i]->path_metric = 0.0f;
+ const path*
+ scl_list::optimal_path()
+ {
+ const path* temp = *std::min_element(d_path_list.begin(),
d_path_list.begin() + d_active_path_counter, path_compare);
+ reset();
+ return temp;
}
- d_active_path_counter = 1;
- d_active_pos = 0;
- }
-
- void
- scl_list::set_info_bit(const int bit_pos)
- {
- if(d_active_path_counter < d_list_size) {
- const int offset = d_active_path_counter;
- for(int i = 0; i < offset; i++) {
- duplicate_path(d_path_list[i + offset], d_path_list[i]);
- d_path_list[i]->path_metric =
update_path_metric(d_path_list[i]->path_metric,
-
d_path_list[i]->llr_vec[bit_pos], 0);
- d_path_list[i + offset]->path_metric = update_path_metric(
- d_path_list[i + offset]->path_metric, d_path_list[i +
offset]->llr_vec[bit_pos], 1);
- d_path_list[i]->u_vec[bit_pos] = 0;
- d_path_list[i + offset]->u_vec[bit_pos] = 1;
+
+ void
+ scl_list::reset()
+ {
+ // leave 0th element active for next iteration
+ d_path_list[0]->path_metric = 0.0f;
+ for(unsigned int i = 1; i < d_path_list.size(); i++){
+ d_path_list[i]->is_active = false;
+ d_path_list[i]->path_metric = 0.0f;
}
+ d_active_path_counter = 1;
+ d_active_pos = 0;
}
- else {
- for(unsigned int i = 0; i < d_list_size; i++) {
- branch_paths(d_path_list[i + d_list_size], d_path_list[i],
d_path_list[i]->llr_vec[bit_pos]);
+ void
+ scl_list::set_info_bit(const int bit_pos)
+ {
+ if(d_active_path_counter < d_list_size) {
+ const int offset = d_active_path_counter;
+ for(int i = 0; i < offset; i++) {
+ duplicate_path(d_path_list[i + offset], d_path_list[i]);
+ d_path_list[i]->path_metric =
update_path_metric(d_path_list[i]->path_metric,
+
d_path_list[i]->llr_vec[bit_pos], 0);
+ d_path_list[i + offset]->path_metric = update_path_metric
+ (d_path_list[i + offset]->path_metric, d_path_list[i +
offset]->llr_vec[bit_pos], 1);
+ d_path_list[i]->u_vec[bit_pos] = 0;
+ d_path_list[i + offset]->u_vec[bit_pos] = 1;
+ }
}
- std::sort(d_path_list.begin(), d_path_list.end(), path_compare);
+ else {
- for(unsigned int i = 0; i < d_list_size; i++) {
- if(!d_path_list[i]->owns_vectors) {
- int t_pos = d_list_size;
- while(!d_path_list[t_pos]->owns_vectors) {
- t_pos++;
- }
- steal_vector_ownership(d_path_list[i], d_path_list[t_pos]);
- d_path_list[i]->u_vec[bit_pos] = 1;
+ for(unsigned int i = 0; i < d_list_size; i++) {
+ branch_paths(d_path_list[i + d_list_size], d_path_list[i],
d_path_list[i]->llr_vec[bit_pos]);
}
- else{
- d_path_list[i]->u_vec[bit_pos] = 0;
+ std::sort(d_path_list.begin(), d_path_list.end(), path_compare);
+
+ for(unsigned int i = 0; i < d_list_size; i++) {
+ if(!d_path_list[i]->owns_vectors) {
+ int t_pos = d_list_size;
+ while(!d_path_list[t_pos]->owns_vectors) {
+ t_pos++;
+ }
+ steal_vector_ownership(d_path_list[i], d_path_list[t_pos]);
+ d_path_list[i]->u_vec[bit_pos] = 1;
+ }
+ else{
+ d_path_list[i]->u_vec[bit_pos] = 0;
+ }
}
}
+ d_active_pos = 0;
}
- d_active_pos = 0;
- }
-
- void
- scl_list::branch_paths(path* target, path* original, const float llr)
- {
- target->path_metric = update_path_metric(original->path_metric, llr,
1);
- original->path_metric = update_path_metric(original->path_metric, llr,
0);
- target->llr_vec = original->llr_vec;
- target->u_vec = original->u_vec;
- }
-
- void
- scl_list::steal_vector_ownership(path* target, path* original)
- {
- memcpy(original->llr_vec, target->llr_vec, sizeof(float) *
d_num_buff_elements);
- memcpy(original->u_vec, target->u_vec, sizeof(unsigned char) *
d_num_buff_elements);
- target->llr_vec = original->llr_vec;
- target->u_vec = original->u_vec;
- target->owns_vectors = true;
- original->owns_vectors = false;
- }
-
- void
- scl_list::duplicate_path(path* target, const path* original)
- {
- memcpy(target->llr_vec, original->llr_vec, sizeof(float) *
d_num_buff_elements);
- memcpy(target->u_vec, original->u_vec, sizeof(unsigned char) *
d_num_buff_elements);
- target->path_metric = original->path_metric;
- d_active_path_counter++;
- target->is_active = true;
- }
-
- float
- scl_list::update_path_metric(const float last_pm, const float llr,
- const float ui) const
- {
- if((ui == 0 && llr > 0.0f) || (ui == 1 && llr < 0.0f)){
-// if(ui == (unsigned char) (0.5 * 1 - copysignf(1.0f, llr))){
- return last_pm;
+
+ void
+ scl_list::branch_paths(path* target, path* original, const float llr)
+ {
+ target->path_metric = update_path_metric(original->path_metric, llr,
1);
+ original->path_metric = update_path_metric(original->path_metric,
llr, 0);
+ target->llr_vec = original->llr_vec;
+ target->u_vec = original->u_vec;
}
- return last_pm + fabs(llr);
- }
-
- void
- scl_list::set_frozen_bit(const unsigned char frozen_bit, const int
bit_pos)
- {
- for(unsigned int i = 0; i < d_active_path_counter; i++){
- d_path_list[i]->u_vec[bit_pos] = frozen_bit;
- d_path_list[i]->path_metric =
update_path_metric(d_path_list[i]->path_metric,
-
d_path_list[i]->llr_vec[bit_pos],
- frozen_bit);
+
+ void
+ scl_list::steal_vector_ownership(path* target, path* original)
+ {
+ memcpy(original->llr_vec, target->llr_vec, sizeof(float) *
d_num_buff_elements);
+ memcpy(original->u_vec, target->u_vec, sizeof(unsigned char) *
d_num_buff_elements);
+ target->llr_vec = original->llr_vec;
+ target->u_vec = original->u_vec;
+ target->owns_vectors = true;
+ original->owns_vectors = false;
+ }
+
+ void
+ scl_list::duplicate_path(path* target, const path* original)
+ {
+ memcpy(target->llr_vec, original->llr_vec, sizeof(float) *
d_num_buff_elements);
+ memcpy(target->u_vec, original->u_vec, sizeof(unsigned char) *
d_num_buff_elements);
+ target->path_metric = original->path_metric;
+ d_active_path_counter++;
+ target->is_active = true;
+ }
+
+ float
+ scl_list::update_path_metric(const float last_pm, const float llr,
+ const float ui) const
+ {
+ if((ui == 0 && llr > 0.0f) || (ui == 1 && llr < 0.0f)){
+ // if(ui == (unsigned char) (0.5 * 1 - copysignf(1.0f,
llr))){
+ return last_pm;
+ }
+ return last_pm + fabs(llr);
+ }
+
+ void
+ scl_list::set_frozen_bit(const unsigned char frozen_bit, const int
bit_pos)
+ {
+ for(unsigned int i = 0; i < d_active_path_counter; i++){
+ d_path_list[i]->u_vec[bit_pos] = frozen_bit;
+ d_path_list[i]->path_metric =
update_path_metric(d_path_list[i]->path_metric,
+
d_path_list[i]->llr_vec[bit_pos],
+ frozen_bit);
+ }
+ d_active_pos = 0;
}
- d_active_pos = 0;
- }
-
- path::path():
- path_metric(0.0f), owns_vectors(false), is_active(false),
llr_vec(NULL), u_vec(NULL)
- {
- }
-
- path::~path(){
- if(owns_vectors){
- volk_free(llr_vec);
- volk_free(u_vec);
+
+ path::path():
+ path_metric(0.0f), owns_vectors(false), is_active(false),
llr_vec(NULL), u_vec(NULL)
+ {
+ }
+
+ path::~path(){
+ if(owns_vectors){
+ volk_free(llr_vec);
+ volk_free(u_vec);
+ }
}
- }
- } /* namespace polar */
+ } /* namespace polar */
} /* namespace code */
} /* namespace fec */
} /* namespace gr */
diff --git a/gr-fec/lib/scl_list.h b/gr-fec/lib/scl_list.h
index d0f62f2..8f3fa66 100644
--- a/gr-fec/lib/scl_list.h
+++ b/gr-fec/lib/scl_list.h
@@ -28,58 +28,58 @@
namespace gr {
namespace fec {
namespace code {
+ namespace polar {
- namespace polar {
- struct path {
- path();
- ~path();
- float path_metric;
- bool owns_vectors;
- bool is_active;
- float* llr_vec;
- unsigned char* u_vec;
- };
+ struct path {
+ path();
+ ~path();
+ float path_metric;
+ bool owns_vectors;
+ bool is_active;
+ float* llr_vec;
+ unsigned char* u_vec;
+ };
- /*!
- * \brief List implementation for Successive Cancellation List decoders
- *
- */
- class scl_list{
- const unsigned int d_list_size;
- const unsigned int d_block_size;
- const unsigned int d_block_power;
- const unsigned int d_num_buff_elements;
- std::vector<path*> d_path_list;
- unsigned int d_active_path_counter;
- unsigned int d_active_pos;
+ /*!
+ * \brief List implementation for Successive Cancellation List decoders
+ *
+ */
+ class scl_list{
+ const unsigned int d_list_size;
+ const unsigned int d_block_size;
+ const unsigned int d_block_power;
+ const unsigned int d_num_buff_elements;
+ std::vector<path*> d_path_list;
+ unsigned int d_active_path_counter;
+ unsigned int d_active_pos;
- float update_path_metric(const float last_pm, const float llr, const
float ui) const;
- void duplicate_path(path* target, const path* original);
- void branch_paths(path* target, path* original, const float llr);
- void steal_vector_ownership(path* target, path* original);
- void reset();
+ float update_path_metric(const float last_pm, const float llr, const
float ui) const;
+ void duplicate_path(path* target, const path* original);
+ void branch_paths(path* target, path* original, const float llr);
+ void steal_vector_ownership(path* target, path* original);
+ void reset();
- // comparator for std::sort
- static bool path_compare(path* first, path* second) {
- return first->path_metric < second->path_metric;
- };
+ // comparator for std::sort
+ static bool path_compare(path* first, path* second) {
+ return first->path_metric < second->path_metric;
+ };
- public:
- scl_list(const unsigned int list_size, const unsigned int block_size,
- const unsigned int block_power);
- virtual
- ~scl_list();
- const unsigned int size() const {return d_list_size;};
- const unsigned int active_size() const {return d_active_path_counter;};
+ public:
+ scl_list(const unsigned int list_size, const unsigned int block_size,
+ const unsigned int block_power);
+ virtual
+ ~scl_list();
+ const unsigned int size() const {return d_list_size;};
+ const unsigned int active_size() const {return
d_active_path_counter;};
- path* initial_path() const {return d_path_list[0];};
- path* next_active_path(){return d_path_list[d_active_pos++];};
- void set_frozen_bit(const unsigned char frozen_bit, const int bit_pos);
- void set_info_bit(const int bit_pos);
- const path* optimal_path();
- };
+ path* initial_path() const {return d_path_list[0];};
+ path* next_active_path(){return d_path_list[d_active_pos++];};
+ void set_frozen_bit(const unsigned char frozen_bit, const int
bit_pos);
+ void set_info_bit(const int bit_pos);
+ const path* optimal_path();
+ };
- } /* namespace polar */
+ } /* namespace polar */
} /* namespace code */
} /* namespace fec */
} /* namespace gr */
- [Commit-gnuradio] [gnuradio] 24/25: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', (continued)
- [Commit-gnuradio] [gnuradio] 24/25: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 07/25: polar: updated polar code example GRC, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 02/25: polar: encoder implemented in C++, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 25/25: Merge remote-tracking branch 'tom/socis/master', git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 06/25: polar: refarctoring and clean-up, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 03/25: polar: SC and SC List decoder implemented in C++, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 01/25: polar: Python test code for polar codes, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 04/25: polar: Python implementation for channel construction, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 13/25: polar: updated documentation and examples, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 15/25: fec: polar: moving polar codes into ::code:: namespace like the others., git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 16/25: fec: polar: whitespace fixes/tabs to go along with namespace change from last commit.,
git <=
- [Commit-gnuradio] [gnuradio] 14/25: polar: updated documentation and examples, git, 2015/09/23