From 51c504ebb1ca21c5f7071826c1af03e45e391a65 Mon Sep 17 00:00:00 2001 From: Daniel Estévez <daniel@destevez.net> Date: Sun, 6 Jun 2021 11:25:57 +0200 Subject: digital: Add NRZI option to differential en/decoder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds an option to the differential encoder an decoder blocks to perform NRZI encoding and decoding. NRZI only makes sense with a modulus of 2, so the blocks constructors will throw and exception if passed nrzi = true and a modulus different from 2. The GRC blocks handle this by hiding the modulus field if the user selects NRZI encoding. A new unit test for the NRZI version of the blocks is added. Besides checking that encode plus decode gives the original, this test also compares the C++ implementation results against a Numpy implementation. Additionally, a faster implementation of differential encoding/ decoding for modulus 2 is included here. Signed-off-by: Daniel Estévez <daniel@destevez.net> --- gr-digital/lib/diff_encoder_bb_impl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gr-digital/lib/diff_encoder_bb_impl.h') diff --git a/gr-digital/lib/diff_encoder_bb_impl.h b/gr-digital/lib/diff_encoder_bb_impl.h index ed8ead0330..03d3f83a19 100644 --- a/gr-digital/lib/diff_encoder_bb_impl.h +++ b/gr-digital/lib/diff_encoder_bb_impl.h @@ -1,6 +1,7 @@ /* -*- c++ -*- */ /* * Copyright 2006,2012 Free Software Foundation, Inc. + * Copyright 2021 Daniel Estevez <daniel@destevez.net> * * This file is part of GNU Radio * @@ -19,7 +20,8 @@ namespace digital { class diff_encoder_bb_impl : public diff_encoder_bb { public: - diff_encoder_bb_impl(unsigned int modulus); + diff_encoder_bb_impl(unsigned int modulus, + enum diff_coding_type coding = DIFF_DIFFERENTIAL); ~diff_encoder_bb_impl() override; int work(int noutput_items, @@ -29,6 +31,7 @@ public: private: unsigned int d_last_out; const unsigned int d_modulus; + const enum diff_coding_type d_coding; }; } /* namespace digital */ -- cgit v1.2.3