Added interleaver

This commit is contained in:
Thomas Kolb 2019-09-14 01:23:26 +02:00
parent 85ce667d7b
commit 1c287466db
13 changed files with 464 additions and 39 deletions

View File

@ -26,5 +26,6 @@ install(FILES
hamnet70_scrambler.xml
hamnet70_async_scrambler.xml
hamnet70_insert_pilot_symbols.xml
hamnet70_correct_frequency_from_pilot_syms.xml DESTINATION share/gnuradio/grc/blocks
hamnet70_correct_frequency_from_pilot_syms.xml
hamnet70_symbol_interleaver.xml DESTINATION share/gnuradio/grc/blocks
)

View File

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<block>
<name>Symbol (De-)Interleaver</name>
<key>hamnet70_symbol_interleaver</key>
<category>[hamnet70]</category>
<import>import hamnet70</import>
<make>hamnet70.symbol_interleaver($interleaver_width, $operation.deinterleave, $length_tag)</make>
<param>
<name>Memory width</name>
<key>interleaver_width</key>
<type>int</type>
<!--value>packet_len</value-->
</param>
<param>
<name>Operation</name>
<key>operation</key>
<type>enum</type>
<option>
<name>Interleave</name>
<key>interleave</key>
<opt>deinterleave:False</opt>
</option>
<option>
<name>Deinterleave</name>
<key>deinterleave</key>
<opt>deinterleave:True</opt>
</option>
</param>
<param>
<name>Length Tag Key</name>
<key>length_tag</key>
<type>string</type>
<!--value>packet_len</value-->
</param>
<sink>
<name>in</name>
<type>complex</type>
</sink>
<source>
<name>out</name>
<type>complex</type>
</source>
</block>

View File

@ -31,5 +31,6 @@ install(FILES
scrambler.h
async_scrambler.h
insert_pilot_symbols.h
correct_frequency_from_pilot_syms.h DESTINATION include/hamnet70
correct_frequency_from_pilot_syms.h
symbol_interleaver.h DESTINATION include/hamnet70
)

View File

@ -0,0 +1,56 @@
/* -*- c++ -*- */
/*
* Copyright 2019 Thomas Kolb.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_HAMNET70_SYMBOL_INTERLEAVER_H
#define INCLUDED_HAMNET70_SYMBOL_INTERLEAVER_H
#include <hamnet70/api.h>
#include <gnuradio/tagged_stream_block.h>
namespace gr {
namespace hamnet70 {
/*!
* \brief <+description of block+>
* \ingroup hamnet70
*
*/
class HAMNET70_API symbol_interleaver : virtual public gr::tagged_stream_block
{
public:
typedef boost::shared_ptr<symbol_interleaver> sptr;
/*!
* \brief Return a shared_ptr to a new instance of hamnet70::symbol_interleaver.
*
* To avoid accidental use of raw pointers, hamnet70::symbol_interleaver's
* constructor is in a private implementation
* class. hamnet70::symbol_interleaver::make is the public interface for
* creating new instances.
*/
static sptr make(size_t interleaver_width = 64, bool deinterleave = false, const std::string &length_tag = "packet_len");
};
} // namespace hamnet70
} // namespace gr
#endif /* INCLUDED_HAMNET70_SYMBOL_INTERLEAVER_H */

View File

@ -35,6 +35,7 @@ list(APPEND hamnet70_sources
async_scrambler_impl.cc
insert_pilot_symbols_impl.cc
correct_frequency_from_pilot_syms_impl.cc
symbol_interleaver_impl.cc
)
set(hamnet70_sources "${hamnet70_sources}" PARENT_SCOPE)

View File

@ -0,0 +1,110 @@
/* -*- c++ -*- */
/*
* Copyright 2019 Thomas Kolb.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "symbol_interleaver_impl.h"
namespace gr {
namespace hamnet70 {
symbol_interleaver::sptr
symbol_interleaver::make(size_t interleaver_width, bool deinterleave, const std::string &length_tag)
{
return gnuradio::get_initial_sptr
(new symbol_interleaver_impl(interleaver_width, deinterleave, length_tag));
}
/*
* The private constructor
*/
symbol_interleaver_impl::symbol_interleaver_impl(size_t interleaver_width, bool deinterleave, const std::string &length_tag)
: gr::tagged_stream_block("symbol_interleaver",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)), length_tag),
d_width(interleaver_width),
d_deinterleave(deinterleave)
{}
/*
* Our virtual destructor.
*/
symbol_interleaver_impl::~symbol_interleaver_impl()
{
}
int
symbol_interleaver_impl::calculate_output_stream_length(const gr_vector_int &ninput_items)
{
int noutput_items = ninput_items[0];
return noutput_items ;
}
int
symbol_interleaver_impl::work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
size_t nitems = ninput_items[0];
size_t ncols = d_width;
size_t nfullcols = nitems % d_width;
size_t nrows = nitems / d_width;
if(nitems % nrows != 0) {
nrows++;
}
size_t row = 0;
size_t col = 0;
for(size_t i = 0; i < nitems; i++) {
size_t swapped_i = ncols * row + col;
row++;
if ((col >= nfullcols && row == (nrows-1))
|| row == nrows) {
col++;
row = 0;
}
if(d_deinterleave) {
out[i] = in[swapped_i];
} else { /* interleave */
out[swapped_i] = in[i];
}
}
noutput_items = nitems;
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace hamnet70 */
} /* namespace gr */

View File

@ -0,0 +1,53 @@
/* -*- c++ -*- */
/*
* Copyright 2019 Thomas Kolb.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_HAMNET70_SYMBOL_INTERLEAVER_IMPL_H
#define INCLUDED_HAMNET70_SYMBOL_INTERLEAVER_IMPL_H
#include <hamnet70/symbol_interleaver.h>
namespace gr {
namespace hamnet70 {
class symbol_interleaver_impl : public symbol_interleaver
{
private:
size_t d_width;
bool d_deinterleave;
protected:
int calculate_output_stream_length(const gr_vector_int &ninput_items);
public:
symbol_interleaver_impl(size_t interleaver_width, bool deinterleave, const std::string &length_tag);
~symbol_interleaver_impl();
// Where all the action really happens
int work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
};
} // namespace hamnet70
} // namespace gr
#endif /* INCLUDED_HAMNET70_SYMBOL_INTERLEAVER_IMPL_H */

View File

@ -51,3 +51,4 @@ set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig)
#GR_ADD_TEST(qa_async_scrambler ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_async_scrambler.py)
#GR_ADD_TEST(qa_insert_pilot_symbols ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_insert_pilot_symbols.py)
#GR_ADD_TEST(qa_correct_frequency_from_pilot_syms ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_correct_frequency_from_pilot_syms.py)
#GR_ADD_TEST(qa_symbol_interleaver ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_symbol_interleaver.py)

View File

@ -0,0 +1,41 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2019 Thomas Kolb.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
from gnuradio import gr, gr_unittest
from gnuradio import blocks
import hamnet70_swig as hamnet70
class qa_symbol_interleaver (gr_unittest.TestCase):
def setUp (self):
self.tb = gr.top_block ()
def tearDown (self):
self.tb = None
def test_001_t (self):
# set up fg
self.tb.run ()
# check data
if __name__ == '__main__':
gr_unittest.run(qa_symbol_interleaver, "qa_symbol_interleaver.xml")

View File

@ -17,6 +17,7 @@
#include "hamnet70/async_scrambler.h"
#include "hamnet70/insert_pilot_symbols.h"
#include "hamnet70/correct_frequency_from_pilot_syms.h"
#include "hamnet70/symbol_interleaver.h"
%}
@ -39,3 +40,5 @@ GR_SWIG_BLOCK_MAGIC2(hamnet70, async_scrambler);
GR_SWIG_BLOCK_MAGIC2(hamnet70, insert_pilot_symbols);
%include "hamnet70/correct_frequency_from_pilot_syms.h"
GR_SWIG_BLOCK_MAGIC2(hamnet70, correct_frequency_from_pilot_syms);
%include "hamnet70/symbol_interleaver.h"
GR_SWIG_BLOCK_MAGIC2(hamnet70, symbol_interleaver);

View File

@ -1327,7 +1327,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(1156, 1121)</value>
<value>(1262, 1122)</value>
</param>
<param>
<key>_rotation</key>
@ -1386,7 +1386,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(918, 922)</value>
<value>(998, 922)</value>
</param>
<param>
<key>_rotation</key>
@ -1472,7 +1472,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(918, 1002)</value>
<value>(998, 1002)</value>
</param>
<param>
<key>_rotation</key>
@ -1609,7 +1609,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(567, 842)</value>
<value>(479, 842)</value>
</param>
<param>
<key>_rotation</key>
@ -2065,7 +2065,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(263, 858)</value>
<value>(231, 858)</value>
</param>
<param>
<key>_rotation</key>
@ -2151,6 +2151,57 @@
<value>1500</value>
</param>
</block>
<block>
<key>hamnet70_symbol_interleaver</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>1</value>
</param>
<param>
<key>_coordinate</key>
<value>(670, 1074)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>hamnet70_symbol_interleaver_0</value>
</param>
<param>
<key>length_tag</key>
<value>packet_len</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>interleaver_width</key>
<value>64</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>operation</key>
<value>deinterleave</value>
</param>
</block>
<block>
<key>import</key>
<param>
@ -2687,25 +2738,7 @@
</connection>
<connection>
<source_block_id>digital_header_payload_demux_0</source_block_id>
<sink_block_id>blocks_rms_xx_0</sink_block_id>
<source_key>1</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>digital_header_payload_demux_0</source_block_id>
<sink_block_id>blocks_sub_xx_0</sink_block_id>
<source_key>1</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>digital_header_payload_demux_0</source_block_id>
<sink_block_id>digital_constellation_decoder_cb_0</sink_block_id>
<source_key>1</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>digital_header_payload_demux_0</source_block_id>
<sink_block_id>digital_constellation_soft_decoder_cf_0</sink_block_id>
<sink_block_id>hamnet70_symbol_interleaver_0</sink_block_id>
<source_key>1</source_key>
<sink_key>0</sink_key>
</connection>
@ -2775,6 +2808,30 @@
<source_key>control_value</source_key>
<sink_key>freq</sink_key>
</connection>
<connection>
<source_block_id>hamnet70_symbol_interleaver_0</source_block_id>
<sink_block_id>blocks_rms_xx_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>hamnet70_symbol_interleaver_0</source_block_id>
<sink_block_id>blocks_sub_xx_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>hamnet70_symbol_interleaver_0</source_block_id>
<sink_block_id>digital_constellation_decoder_cb_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>hamnet70_symbol_interleaver_0</source_block_id>
<sink_block_id>digital_constellation_soft_decoder_cf_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>pad_source_0</source_block_id>
<sink_block_id>blocks_multiply_xx_0</sink_block_id>

View File

@ -618,7 +618,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(1765, 423)</value>
<value>(1980, 391)</value>
</param>
<param>
<key>_rotation</key>
@ -677,7 +677,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(1525, 283)</value>
<value>(1709, 251)</value>
</param>
<param>
<key>_rotation</key>
@ -1136,7 +1136,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(1980, 435)</value>
<value>(2196, 403)</value>
</param>
<param>
<key>_rotation</key>
@ -1160,13 +1160,64 @@
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
<value>base_buffer_size</value>
</param>
<param>
<key>pilot_sequence</key>
<value>[1+1j, -1-1j, 1-1j, -1+1j]</value>
</param>
</block>
<block>
<key>hamnet70_symbol_interleaver</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>1</value>
</param>
<param>
<key>_coordinate</key>
<value>(1733, 483)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>hamnet70_symbol_interleaver_0</value>
</param>
<param>
<key>length_tag</key>
<value>packet_len</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>interleaver_width</key>
<value>64</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>operation</key>
<value>interleave</value>
</param>
</block>
<block>
<key>import</key>
<param>
@ -1398,7 +1449,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(2188, 451)</value>
<value>(2404, 419)</value>
</param>
<param>
<key>_rotation</key>
@ -1478,9 +1529,9 @@
</connection>
<connection>
<source_block_id>digital_chunks_to_symbols_xx_0</source_block_id>
<sink_block_id>blocks_tagged_stream_mux_0</sink_block_id>
<sink_block_id>hamnet70_symbol_interleaver_0</sink_block_id>
<source_key>0</source_key>
<sink_key>2</sink_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>digital_chunks_to_symbols_xx_0_0</source_block_id>
@ -1530,6 +1581,12 @@
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>hamnet70_symbol_interleaver_0</source_block_id>
<sink_block_id>blocks_tagged_stream_mux_0</sink_block_id>
<source_key>0</source_key>
<sink_key>2</sink_key>
</connection>
<connection>
<source_block_id>interp_fir_filter_xxx_0</source_block_id>
<sink_block_id>pad_sink_0</sink_block_id>

View File

@ -533,7 +533,7 @@
</param>
<param>
<key>tags</key>
<value>tagged_streams.make_lengthtags((256,), (0,), "packet_len")</value>
<value>tagged_streams.make_lengthtags((1000,), (0,), "packet_len")</value>
</param>
<param>
<key>vlen</key>
@ -541,7 +541,7 @@
</param>
<param>
<key>vector</key>
<value>list(range(256))</value>
<value>[x%256 for x in range(1000)]</value>
</param>
</block>
<block>
@ -1383,11 +1383,11 @@
</param>
<param>
<key>_enabled</key>
<value>0</value>
<value>1</value>
</param>
<param>
<key>fftsize</key>
<value>8192</value>
<value>1024</value>
</param>
<param>
<key>_coordinate</key>
@ -1447,7 +1447,7 @@
</param>
<param>
<key>rate</key>
<value>1</value>
<value>10</value>
</param>
<param>
<key>wintype</key>
@ -1486,7 +1486,7 @@
</param>
<param>
<key>_enabled</key>
<value>True</value>
<value>0</value>
</param>
<param>
<key>_coordinate</key>