Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

gr: add pmtf::pdu construct #243

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blocklib/digital/chunks_to_symbols/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
meson.build
62 changes: 62 additions & 0 deletions blocklib/digital/chunks_to_symbols/chunks_to_symbols.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module: digital
block: chunks_to_symbols
label: Chunks to Symbols
blocktype: block
flags:
- pdu

doc:
brief: |-
Map a stream of unpacked symbol indexes to stream of
float or complex constellation points in D dimensions (D = 1 by
default)
detail: |-
\li input: stream of IN_T
\li output: stream of OUT_T
\li out[n D + k] = symbol_table[in[n] D + k], k=0,1,...,D-1
The combination of gr::blocks::packed_to_unpacked_XX followed
by gr::digital::chunks_to_symbols_XY handles the general case
of mapping from a stream of bytes or shorts into arbitrary
float or complex symbols.

typekeys:
- id: IN_T
type: class
options:
- ru8
- ru16
- ru32
- id: OUT_T
type: class
options:
- cf32
- rf32

parameters:
- id: symbol_table
label: Symbol Table
dtype: OUT_T
settable: true
container: vector
- id: D
label: Dimension
dtype: size_t
settable: false
default: 1

ports:
- domain: stream
id: in
direction: input
type: typekeys/IN_T

- domain: stream
id: out
direction: output
type: typekeys/OUT_T

implementations:
- id: cpu
# - id: cuda

file_format: 1
70 changes: 70 additions & 0 deletions blocklib/digital/chunks_to_symbols/chunks_to_symbols_cpu.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* -*- c++ -*- */
/*
* Copyright 2022 FIXME
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/

#include "chunks_to_symbols_cpu.h"
#include "chunks_to_symbols_cpu_gen.h"

namespace gr {
namespace digital {

template <class IN_T, class OUT_T>
chunks_to_symbols_cpu<IN_T, OUT_T>::chunks_to_symbols_cpu(
const typename chunks_to_symbols<IN_T, OUT_T>::block_args& args)
: INHERITED_CONSTRUCTORS(IN_T, OUT_T)
{
this->set_output_multiple(args.D);
}

template <class IN_T, class OUT_T>
work_return_code_t
chunks_to_symbols_cpu<IN_T, OUT_T>::work(std::vector<block_work_input_sptr>& work_input,
std::vector<block_work_output_sptr>& work_output)
{
auto in = work_input[0]->items<IN_T>();
auto out = work_output[0]->items<OUT_T>();

auto noutput = work_output[0]->n_items;
auto ninput = work_input[0]->n_items;

auto d_D = pmtf::get_as<size_t>(*this->param_D);

// number of inputs to consume
auto in_count = std::min(ninput, noutput / d_D);
if (in_count < 1) {
return work_return_code_t::WORK_INSUFFICIENT_OUTPUT_ITEMS;
}

auto d_symbol_table = pmtf::get_as<std::vector<OUT_T>>(*this->param_symbol_table);

if (d_D == 1) {
for (size_t i = 0; i < in_count; i++) {
auto key = static_cast<size_t>(*in);
*out = d_symbol_table[key];
++out;
++in;
}
}
else { // the multi-dimensional case
for (size_t i = 0; i < in_count; i++) {
auto key = static_cast<size_t>(*in) * d_D;
for (size_t idx = 0; idx < d_D; ++idx) {
*out = d_symbol_table[key + idx];
++out;
}
++in;
}
}

this->consume_each(in_count, work_input);
this->produce_each(in_count * d_D, work_output);
return work_return_code_t::WORK_OK;
}
} // namespace digital
} // namespace gr
33 changes: 33 additions & 0 deletions blocklib/digital/chunks_to_symbols/chunks_to_symbols_cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* -*- c++ -*- */
/*
* Copyright 2022 FIXME
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/

#pragma once

#include <gnuradio/digital/chunks_to_symbols.h>

namespace gr {
namespace digital {

template <class IN_T, class OUT_T>
class chunks_to_symbols_cpu : public chunks_to_symbols<IN_T, OUT_T>
{
public:
chunks_to_symbols_cpu(const typename chunks_to_symbols<IN_T, OUT_T>::block_args& args);

virtual work_return_code_t work(std::vector<block_work_input_sptr>& work_input,
std::vector<block_work_output_sptr>& work_output) override;

private:
// Declare private variables here
};


} // namespace digital
} // namespace gr
22 changes: 16 additions & 6 deletions blocklib/digital/meson.build
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
#autogenerated
# This file has been automatically generated and will be overwritten by meson build
# Remove the #autogenerated comment at the top if you wish for the build scripts to leave
# this file alone

subdir('include/gnuradio/digital')

digital_sources = []
digital_cu_sources = []
digital_pure_python_sources = []
digital_pybind_sources = []
digital_pybind_names = []
digital_deps = []



# Individual block subdirectories
subdir('ofdm_cyclic_prefixer')
subdir('chunks_to_symbols')


subdir('lib')
# if (get_option('enable_python'))
# subdir('python/digital')
# endif
if (get_option('enable_python'))
subdir('python/digital')
endif

# if (get_option('enable_testing'))
# subdir('test')
# endif
if (get_option('enable_testing'))
subdir('test')
endif
1 change: 1 addition & 0 deletions blocklib/digital/ofdm_cyclic_prefixer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
meson.build
67 changes: 67 additions & 0 deletions blocklib/digital/ofdm_cyclic_prefixer/ofdm_cyclic_prefixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module: digital
block: ofdm_cyclic_prefixer
label: ofdm_cyclic_prefixer
blocktype: block
flags:
- pdu

doc:
brief: Adds a cyclic prefix and performs optional pulse shaping on OFDM symbols.
detail: |-
Input: OFDM symbols (in the time domain, i.e. after the IFFT). Optionally,
entire frames can be processed.
Output: A stream of (scalar) complex symbols, which include the cyclic prefix
and the pulse shaping.
Note: If complete frames are processed, and \p rolloff_len is greater
than zero, the final OFDM symbol is followed by the delay line of
the pulse shaping.

The pulse shape is a raised cosine in the time domain.

Different CP lengths as for instance needed in LTE are supported. This
is why one of the inputs is std::vector<int>. After every CP given has
been prepended to symbols, each with the length of the IFFT operation,
the mechanism will wrap around and start over. To give an example, the
input tuple for LTE with an FFT length of 2048 would be (160,) +
(144,)*6, which is equal to (160, 144, 144, 144, 144, 144, 144). A
uniform CP would be indicated by (uniform_cp_length, ).

This block does some sanity checking: 1. It is not allowed to have a
vector of CP lengths, which are only 0. 2. Not a single CP in the
vector must be longer than the rolloff. 3. Not a single CP is allowed to
be < 0.

parameters:
- id: fft_len
label: IFFT Length
dtype: size_t
settable: false
- id: cp_lengths
label: CP Lengths
dtype: size_t
container: vector
settable: false
- id: rolloff_len
label: Rollof Length
dtype: size_t
default: 0
settable: false

ports:
- domain: stream
id: in
direction: input
type: gr_complex
shape: parameters/fft_len

- domain: stream
id: out
direction: output
type: gr_complex


implementations:
- id: cpu
# - id: cuda

file_format: 1
Loading