From 15a8cce4dadaa895081d1d9816f37e65117cffb5 Mon Sep 17 00:00:00 2001 From: JaredD <jareddpub@gmail.com> Date: Mon, 19 Jul 2021 04:41:18 -0600 Subject: blocks: add matrix interleaver block * blocks: add matrix interleaver block Matrix interleaver including qa test and example The matrix interleaver is a hierarchical block that pairs a base deinterleave block that effectively writes samples into "rows" (1 block of samples per output) and a base interleave block that outputs samples iteratively from each input like "columns". Signed-off-by: Jared Dulmage <jared.dulmage@caliola.com> Add grc file and update blocks.tree.yml. Fix module for matrix interleaver example Signed-off-by: Jared Dulmage <jared.dulmage@caliola.com> * Update py file docs and license block Co-authored-by: Jared Dulmage <jared.dulmage@caliola.com> --- gr-blocks/python/blocks/matrix_interleaver.py | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 gr-blocks/python/blocks/matrix_interleaver.py (limited to 'gr-blocks/python/blocks/matrix_interleaver.py') diff --git a/gr-blocks/python/blocks/matrix_interleaver.py b/gr-blocks/python/blocks/matrix_interleaver.py new file mode 100644 index 0000000000..26a8e86a6e --- /dev/null +++ b/gr-blocks/python/blocks/matrix_interleaver.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2021 Caliola Engineering, LLC. +# +# This file is part of GNU Radio +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +from gnuradio import gr, blocks + +class matrix_interleaver(gr.hier_block2): + """ + Block interleaver writes inputs into conceptual rows of the matrix + and reads outputs by conceptual columns of the matrix. + In deinterleaver mode it writes inputs into conceptual columns + and reads outputs by conceptual rows. + """ + + def __init__(self, itemsize, rows=1, cols=1, deint=False): + gr.hier_block2.__init__( + self, "Matrix Interleaver", + gr.io_signature(1, 1, itemsize), + gr.io_signature(1, 1, itemsize), + ) + + self.itemsize = itemsize + self.set_rowsandcols(rows, cols, deint) + + def set_rowsandcols(self, rows, cols, deint): + self.disconnect_all() + + self.passthrough = None + self.interleaver = None + self.deinterleaver = None + + ################################################## + # Parameters + ################################################## + self.rows = rows + self.cols = cols + self.deint = deint + + ################################################## + # Blocks + ################################################## + # short circuit for unitary rows / columns + if rows == 1 or cols == 1: + self.passthrough = blocks.copy(self.itemsize) + self.connect((self, 0), (self.passthrough, 0), (self, 0)) + return + + self.deinterleaver = blocks.deinterleave(self.itemsize, 1 if deint else cols) + self.interleaver = blocks.interleave(self.itemsize, cols if deint else 1) + + ################################################## + # Connections + ################################################## + self.connect((self, 0), (self.deinterleaver, 0)) + for n in range(rows): + self.connect((self.deinterleaver, n), (self.interleaver, n)) + self.connect((self.interleaver, 0), (self, 0)) -- cgit v1.2.3