aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--notebooks/Untitled.ipynb278
-rwxr-xr-xtests/Map/Map_test.py149
-rw-r--r--tests/Map/Map_tets.grc280
-rw-r--r--tests/Map/epy_block_1.py27
4 files changed, 734 insertions, 0 deletions
diff --git a/notebooks/Untitled.ipynb b/notebooks/Untitled.ipynb
new file mode 100644
index 0000000..23109f8
--- /dev/null
+++ b/notebooks/Untitled.ipynb
@@ -0,0 +1,278 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "9aef28b0",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import numpy as np "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "412e054c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def modulate_qpsk(m):\n",
+ " ampl = np.sqrt(2)\n",
+ " sym = {\n",
+ " 0: ampl * (-1 -1j)/np.sqrt(2),\n",
+ " 1: ampl * ( 1 -1j)/np.sqrt(2),\n",
+ " 2: ampl * (-1 +1j)/np.sqrt(2),\n",
+ " 3: ampl * ( 1 +1j)/np.sqrt(2)\n",
+ " }\n",
+ "\n",
+ " return map(lambda k: sym[k], m)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "c340fb0f",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "<map at 0x7f2fe63da820>"
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "modulate_qpsk([0])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "b4881afe",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'0x1f'"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "hex(31)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "id": "2c43411f",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'0b1010101'"
+ ]
+ },
+ "execution_count": 24,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "bin(0x55)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "f65a2e47",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(0.7071067811865475+0.7071067811865475j)"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "a=(1 +1j)/np.sqrt(2)\n",
+ "a"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "3c15cd13",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(-9.486832980505138-9.486832980505138j)"
+ ]
+ },
+ "execution_count": 7,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "-3/np.sqrt(0.1)-3j/np.sqrt(0.1)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "id": "cb3fdfcc",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def modulate_16qam(m):\n",
+ " sym = {\n",
+ " # first column\n",
+ " 0: -3 -3j,\n",
+ " 1: -3 -1j,\n",
+ " 2: -3 +3j,\n",
+ " 3: -3 +1j,\n",
+ " # second column\n",
+ " 4: -1 -3j,\n",
+ " 5: -1 -1j,\n",
+ " 6: -1 +3j,\n",
+ " 7: -1 +1j,\n",
+ " # fourth column\n",
+ " 8: 3 -3j,\n",
+ " 9: 3 -1j,\n",
+ " 10: 3 +3j,\n",
+ " 11: 3 +1j,\n",
+ " # third column\n",
+ " 12: 1 -3j,\n",
+ " 13: 1 -1j,\n",
+ " 14: 1 +3j,\n",
+ " 15: 1 +1j,\n",
+ " }\n",
+ " return map(lambda k: sym[k]*np.sqrt(0.1), m)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "id": "01626f53",
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[(-0.9486832980505138-0.31622776601683794j),\n",
+ " (-0.9486832980505138-0.31622776601683794j)]"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "list(modulate_16qam([1, 1]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "id": "df5b6858",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def modulate_16qam_2(m):\n",
+ " sym = {\n",
+ " # first column\n",
+ " 0: 1 -1j,\n",
+ " 1: -1 -1j,\n",
+ " 2: 3 -3j,\n",
+ " 3: -3 -3j,\n",
+ " 4: -3 -1j,\n",
+ " 5: 3 -1j,\n",
+ " 6: -1 -3j,\n",
+ " 7: 1 -3j,\n",
+ " 8: -3 +3j,\n",
+ " 9: 3 +3j,\n",
+ " 10: -1 +1j,\n",
+ " 11: 1 +1j,\n",
+ " 12: 1 +3j,\n",
+ " 13: -1 +3j,\n",
+ " 14: 3 +1j,\n",
+ " 15: -3 +1j,\n",
+ " \n",
+ " }\n",
+ " return map(lambda k: sym[k]*np.sqrt(0.1), m)\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 23,
+ "id": "f263ed95",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[(-0.31622776601683794-0.31622776601683794j),\n",
+ " (-0.31622776601683794-0.31622776601683794j)]"
+ ]
+ },
+ "execution_count": 23,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "list(modulate_16qam_2([1,1]))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "27855d88",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.9.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/tests/Map/Map_test.py b/tests/Map/Map_test.py
new file mode 100755
index 0000000..f7b478f
--- /dev/null
+++ b/tests/Map/Map_test.py
@@ -0,0 +1,149 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+#
+# SPDX-License-Identifier: GPL-3.0
+#
+# GNU Radio Python Flow Graph
+# Title: Map test
+# Author: Sara Halter
+# GNU Radio version: 3.8.2.0
+
+from gnuradio import blocks
+from gnuradio import digital
+from gnuradio import gr
+from gnuradio.filter import firdes
+import sys
+import signal
+from argparse import ArgumentParser
+from gnuradio.eng_arg import eng_float, intx
+from gnuradio import eng_notation
+import epy_block_1
+import numpy as np
+
+
+class Map_test(gr.top_block):
+
+ def __init__(self):
+ gr.top_block.__init__(self, "Map test")
+
+ ##################################################
+ # Variables
+ ##################################################
+ self.v3 = v3 = 0.7071067811865475+0.7071067811865475j
+ self.v2 = v2 = -0.7071067811865475+0.7071067811865475j
+ self.v1 = v1 = 0.7071067811865475-0.7071067811865475j
+ self.v0 = v0 = -0.7071067811865475-0.7071067811865475j
+ self.samp_rate = samp_rate = 32000
+ self.const = const = digital.constellation_16qam().base()
+ self.a3 = a3 = -9.486832980505138-9.486832980505138j
+ self.a2 = a2 = 9.486832980505138-9.486832980505138j
+ self.a1 = a1 = -3.162277660168379-3.162277660168379j
+ self.a0 = a0 = 3.162277660168379-3.162277660168379j
+
+ ##################################################
+ # Blocks
+ ##################################################
+ self.epy_block_1 = epy_block_1.blk()
+ self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const)
+ self.blocks_vector_source_x_1_0 = blocks.vector_source_c([(-0.9486832980505138-0.31622776601683794j), (-0.9486832980505138-0.31622776601683794j)], True, 1, [])
+ self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(2, 8, "", False, gr.GR_MSB_FIRST)
+
+
+
+ ##################################################
+ # Connections
+ ##################################################
+ self.connect((self.blocks_repack_bits_bb_0, 0), (self.epy_block_1, 0))
+ self.connect((self.blocks_vector_source_x_1_0, 0), (self.digital_constellation_decoder_cb_0, 0))
+ self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_repack_bits_bb_0, 0))
+
+
+ def get_v3(self):
+ return self.v3
+
+ def set_v3(self, v3):
+ self.v3 = v3
+
+ def get_v2(self):
+ return self.v2
+
+ def set_v2(self, v2):
+ self.v2 = v2
+
+ def get_v1(self):
+ return self.v1
+
+ def set_v1(self, v1):
+ self.v1 = v1
+
+ def get_v0(self):
+ return self.v0
+
+ def set_v0(self, v0):
+ self.v0 = v0
+
+ def get_samp_rate(self):
+ return self.samp_rate
+
+ def set_samp_rate(self, samp_rate):
+ self.samp_rate = samp_rate
+
+ def get_const(self):
+ return self.const
+
+ def set_const(self, const):
+ self.const = const
+
+ def get_a3(self):
+ return self.a3
+
+ def set_a3(self, a3):
+ self.a3 = a3
+
+ def get_a2(self):
+ return self.a2
+
+ def set_a2(self, a2):
+ self.a2 = a2
+
+ def get_a1(self):
+ return self.a1
+
+ def set_a1(self, a1):
+ self.a1 = a1
+
+ def get_a0(self):
+ return self.a0
+
+ def set_a0(self, a0):
+ self.a0 = a0
+
+
+
+
+
+def main(top_block_cls=Map_test, options=None):
+ tb = top_block_cls()
+
+ def sig_handler(sig=None, frame=None):
+ tb.stop()
+ tb.wait()
+
+ sys.exit(0)
+
+ signal.signal(signal.SIGINT, sig_handler)
+ signal.signal(signal.SIGTERM, sig_handler)
+
+ tb.start()
+
+ try:
+ input('Press Enter to quit: ')
+ except EOFError:
+ pass
+ tb.stop()
+ tb.wait()
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tests/Map/Map_tets.grc b/tests/Map/Map_tets.grc
new file mode 100644
index 0000000..1002b25
--- /dev/null
+++ b/tests/Map/Map_tets.grc
@@ -0,0 +1,280 @@
+options:
+ parameters:
+ author: 'Sara Halter '
+ category: '[GRC Hier Blocks]'
+ cmake_opt: ''
+ comment: ''
+ copyright: ''
+ description: ''
+ gen_cmake: 'On'
+ gen_linking: dynamic
+ generate_options: no_gui
+ hier_block_src_path: '.:'
+ id: Map_test
+ max_nouts: '0'
+ output_language: python
+ placement: (0,0)
+ qt_qss_theme: ''
+ realtime_scheduling: ''
+ run: 'True'
+ run_command: '{python} -u {filename}'
+ run_options: prompt
+ sizing_mode: fixed
+ thread_safe_setters: ''
+ title: Map test
+ window_size: ''
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [8, 8]
+ rotation: 0
+ state: enabled
+
+blocks:
+- name: a0
+ id: variable
+ parameters:
+ comment: ''
+ value: 3.162277660168379-3.162277660168379j
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [552, 52.0]
+ rotation: 0
+ state: enabled
+- name: a1
+ id: variable
+ parameters:
+ comment: ''
+ value: -3.162277660168379-3.162277660168379j
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [552, 116.0]
+ rotation: 0
+ state: enabled
+- name: a2
+ id: variable
+ parameters:
+ comment: ''
+ value: 9.486832980505138-9.486832980505138j
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [552, 180.0]
+ rotation: 0
+ state: enabled
+- name: a3
+ id: variable
+ parameters:
+ comment: ''
+ value: -9.486832980505138-9.486832980505138j
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [552, 244.0]
+ rotation: 0
+ state: enabled
+- name: const
+ id: variable_constellation
+ parameters:
+ comment: ''
+ const_points: '[-1-1j, -1+1j, 1+1j, 1-1j]'
+ dims: '1'
+ precision: '8'
+ rot_sym: '4'
+ soft_dec_lut: None
+ sym_map: '[0, 1, 3, 2]'
+ type: 16qam
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [264, 420.0]
+ rotation: 0
+ state: enabled
+- name: samp_rate
+ id: variable
+ parameters:
+ comment: ''
+ value: '32000'
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [184, 12.0]
+ rotation: 0
+ state: enabled
+- name: v0
+ id: variable
+ parameters:
+ comment: ''
+ value: -0.7071067811865475-0.7071067811865475j
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [712, 428.0]
+ rotation: 0
+ state: enabled
+- name: v1
+ id: variable
+ parameters:
+ comment: ''
+ value: 0.7071067811865475-0.7071067811865475j
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [712, 492.0]
+ rotation: 0
+ state: enabled
+- name: v2
+ id: variable
+ parameters:
+ comment: ''
+ value: -0.7071067811865475+0.7071067811865475j
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [712, 556.0]
+ rotation: 0
+ state: enabled
+- name: v3
+ id: variable
+ parameters:
+ comment: ''
+ value: 0.7071067811865475+0.7071067811865475j
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [712, 620.0]
+ rotation: 0
+ state: enabled
+- name: blocks_repack_bits_bb_0
+ id: blocks_repack_bits_bb
+ parameters:
+ affinity: ''
+ alias: ''
+ align_output: 'False'
+ comment: ''
+ endianness: gr.GR_MSB_FIRST
+ k: '2'
+ l: '8'
+ len_tag_key: '""'
+ maxoutbuf: '0'
+ minoutbuf: '0'
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [1376, 324.0]
+ rotation: 0
+ state: true
+- name: blocks_vector_source_x_1_0
+ id: blocks_vector_source_x
+ parameters:
+ affinity: ''
+ alias: ''
+ comment: ''
+ maxoutbuf: '0'
+ minoutbuf: '0'
+ repeat: 'True'
+ tags: '[]'
+ type: complex
+ vector: '[(-0.9486832980505138-0.31622776601683794j), (-0.9486832980505138-0.31622776601683794j)]'
+ vlen: '1'
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [704, 316.0]
+ rotation: 0
+ state: enabled
+- name: digital_constellation_decoder_cb_0
+ id: digital_constellation_decoder_cb
+ parameters:
+ affinity: ''
+ alias: ''
+ comment: ''
+ constellation: const
+ maxoutbuf: '0'
+ minoutbuf: '0'
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [976, 332.0]
+ rotation: 0
+ state: true
+- name: digital_map_bb_0
+ id: digital_map_bb
+ parameters:
+ affinity: ''
+ alias: ''
+ comment: ''
+ map: '[0, 1, 3, 2]'
+ maxoutbuf: '0'
+ minoutbuf: '0'
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [1216, 332.0]
+ rotation: 0
+ state: bypassed
+- name: epy_block_1
+ id: epy_block
+ parameters:
+ _source_code: "\"\"\"\nEmbedded Python Blocks:\n\nEach time this file is saved,\
+ \ GRC will instantiate the first class it finds\nto get ports and parameters\
+ \ of your block. The arguments to __init__ will\nbe the parameters. All of\
+ \ them are required to have default values!\n\"\"\"\n\nimport numpy as np\n\
+ from gnuradio import gr\n\nnp.set_printoptions(formatter={'int':hex})\n\nclass\
+ \ blk(gr.sync_block):\n def __init__(self):\n gr.sync_block.__init__(\n\
+ \ self,\n name='Printer',\n in_sig=[np.byte],\n\
+ \ out_sig=[]\n )\n\n def work(self, input_items, output_items):\n\
+ \ inp = np.array(input_items[0], dtype=np.uint8)\n print(f\"Decoded\
+ \ {len(inp)} samples:\\n{inp}\")\n\n return len(inp)\n"
+ affinity: ''
+ alias: ''
+ comment: ''
+ maxoutbuf: '0'
+ minoutbuf: '0'
+ states:
+ _io_cache: ('Printer', 'blk', [], [('0', 'byte', 1)], [], '', [])
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [1664, 336.0]
+ rotation: 0
+ state: enabled
+- name: import_0
+ id: import
+ parameters:
+ alias: ''
+ comment: ''
+ imports: import numpy as np
+ states:
+ bus_sink: false
+ bus_source: false
+ bus_structure: null
+ coordinate: [272, 20.0]
+ rotation: 0
+ state: true
+
+connections:
+- [blocks_repack_bits_bb_0, '0', epy_block_1, '0']
+- [blocks_vector_source_x_1_0, '0', digital_constellation_decoder_cb_0, '0']
+- [digital_constellation_decoder_cb_0, '0', digital_map_bb_0, '0']
+- [digital_map_bb_0, '0', blocks_repack_bits_bb_0, '0']
+
+metadata:
+ file_format: 1
diff --git a/tests/Map/epy_block_1.py b/tests/Map/epy_block_1.py
new file mode 100644
index 0000000..d30c2eb
--- /dev/null
+++ b/tests/Map/epy_block_1.py
@@ -0,0 +1,27 @@
+"""
+Embedded Python Blocks:
+
+Each time this file is saved, GRC will instantiate the first class it finds
+to get ports and parameters of your block. The arguments to __init__ will
+be the parameters. All of them are required to have default values!
+"""
+
+import numpy as np
+from gnuradio import gr
+
+np.set_printoptions(formatter={'int':hex})
+
+class blk(gr.sync_block):
+ def __init__(self):
+ gr.sync_block.__init__(
+ self,
+ name='Printer',
+ in_sig=[np.byte],
+ out_sig=[]
+ )
+
+ def work(self, input_items, output_items):
+ inp = np.array(input_items[0], dtype=np.uint8)
+ print(f"Decoded {len(inp)} samples:\n{inp}")
+
+ return len(inp)